function kdmail($f) { $this->load('lib/phpmailer/class.phpmailer'); $mail = new PHPMailer(); //$body = $mail->getFile(ROOT.'index.php'); //$body = eregi_replace("[\]",'',$body); $mail->IsSendmail(); // telling the class to use SendMail transport $mail->From = $f["from"]; $mail->FromName = either($f["fromname"], "noticer"); $mail->Subject = either($f["subject"], "hello"); //$mail->AltBody = either($f["altbody"], "To view the message, please use an HTML compatible email viewer!"); // optional, comment out and test $mail->AltBody = either($f["msg"], "To view the message, please use an HTML compatible email viewer!"); // optional, comment out and test if ($f["embedimg"]) { foreach ($f["embedimg"] as $i) { //$mail->AddEmbeddedImage(ROOT."public/images/logo7.png","logo","logo7.png"); $mail->AddEmbeddedImage($i[0], $i[1], $i[2]); } } if ($f["msgfile"]) { $body = $mail->getFile($f["msgfile"]); $body = eregi_replace("[\\]", '', $body); if ($f["type"] == "text") { $mail->IsHTML(false); $mail->Body = $body; } else { $mail->MsgHTML($body); //."<br><img src= \"cid:logo\">"); } } else { if ($f["type"] == "text") { $mail->IsHTML(false); $mail->Body = $f["msg"]; } else { $mail->MsgHTML($f["msg"]); //."<br><img src= \"cid:logo\">"); } } if (preg_match('/\\,/', $f["to"])) { $emails = explode(",", $f["to"]); foreach ($emails as $i) { $mail->AddAddress($i, $f["toname"]); } } else { $mail->AddAddress($f["to"], $f["toname"]); } $mail->AddBCC($this->config["site"]["mail"], "bcc"); if ($f["files"]) { foreach ($f["files"] as $i) { $mail->AddAttachment($i); // attachment } } if (!$mail->Send()) { return "Mailer Error: " . $mail->ErrorInfo; } else { return "Message sent!"; } }
function index() { $dsn = array(); $this->sv("rooturl", preg_replace('/&t=.*/', '', $_SERVER['REQUEST_URI'])); if (f('submit')) { $dsn['dbHost'] = either(f("host"), "db4free.net"); $dsn['port'] = either(f("port"), 3306); $dsn['dbHost'] .= ":" . $dsn['port']; $dsn['dbName'] = either(f("db"), "greedisok"); $dsn['dbUser'] = either(f("user"), "greedisok"); $dsn['dbPswd'] = either(f("pass"), 'greedisok'); $dsn["charset"] = ""; include_once ROOT . "lib/vip/DBUtil.php"; $db = new DB($dsn); include_once ROOT . "app/main/model.php"; $modelobj = new model($db); $this->sv("dsn", $dsn); try { $this->sv("table_list", $modelobj->table_names()); $table = f('t'); if ($table) { $modelobj->change_table($table); $table_detail = $modelobj->detail(); $this->sv("table_detail", $table_detail); } } catch (Exception $e) { $this->sv("info", $e->getMessage()); } } }
public static function array_to_multibulk($array) { $multi = array(); foreach ($array as $key => $val) { array_push($multi, $key, either($val, '')); } return $multi; }
public function __construct($id) { $this->id = either($id, uniqid()); $this->exists = false; $data = Util::multibulk_to_array(Redis::hgetall($this->key())); foreach ($data as $key => $val) { $this->{$key} = json_decode($val, true); } $this->exists = count($data) > 0; }
function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { // Note: the following change to the Request is router-specific and it's not required by other middleware. // Only the router uses a mutating requestTarget to handle sub-routes. // TODO: route using UriInterface and do not change requestTarget. /** @var ServerRequestInterface $request */ $request = $request->withRequestTarget(either($request->getAttribute('virtualUri'), '.')); //---------- return parent::__invoke($request, $response, $next); }
private function compile(array $tokens) { $cg = (object) ['ts' => TokenStream::fromSlice($tokens), 'parsers' => []]; traverse(rtoken('/^(T_\\w+)·(\\w+)$/')->onCommit(function (Ast $result) use($cg) { $token = $result->token(); $id = $this->lookupCapture($token); $type = $this->lookupTokenType($token); $cg->parsers[] = token($type)->as($id); }), ($parser = chain(rtoken('/^·\\w+$/')->as('type'), token('('), optional(ls(either(future($parser)->as('parser'), chain(token(T_FUNCTION), parentheses()->as('args'), braces()->as('body'))->as('function'), string()->as('string'), rtoken('/^T_\\w+·\\w+$/')->as('token'), rtoken('/^T_\\w+$/')->as('constant'), rtoken('/^·this$/')->as('this'), label()->as('label'))->as('parser'), token(',')))->as('args'), commit(token(')')), optional(rtoken('/^·\\w+$/')->as('label'), null)))->onCommit(function (Ast $result) use($cg) { $cg->parsers[] = $this->compileParser($result->type, $result->args, $result->label); }), $this->layer('{', '}', braces(), $cg), $this->layer('[', ']', brackets(), $cg), $this->layer('(', ')', parentheses(), $cg), rtoken('/^···(\\w+)$/')->onCommit(function (Ast $result) use($cg) { $id = $this->lookupCapture($result->token()); $cg->parsers[] = layer()->as($id); }), token(T_STRING, '·')->onCommit(function (Ast $result) use($cg) { $offset = \count($cg->parsers); if (0 !== $this->dominance || 0 === $offset) { $this->fail(self::E_BAD_DOMINANCE, $offset, $result->token()->line()); } $this->dominance = $offset; }), rtoken('/·/')->onCommit(function (Ast $result) { $token = $result->token(); $this->fail(self::E_BAD_CAPTURE, $token, $token->line()); }), any()->onCommit(function (Ast $result) use($cg) { $cg->parsers[] = token($result->token()); }))->parse($cg->ts); // check if macro dominance '·' is last token if ($this->dominance === \count($cg->parsers)) { $this->fail(self::E_BAD_DOMINANCE, $this->dominance, $cg->ts->last()->line()); } $this->specificity = \count($cg->parsers); if ($this->specificity > 1) { if (0 === $this->dominance) { $pattern = chain(...$cg->parsers); } else { /* dominat macros are partially wrapped in commit()s and dominance is the offset used as the 'event horizon' point... once the entry point is matched, there is no way back and a parser error arises */ $prefix = array_slice($cg->parsers, 0, $this->dominance); $suffix = array_slice($cg->parsers, $this->dominance); $pattern = chain(...array_merge($prefix, array_map(commit::class, $suffix))); } } else { /* micro optimization to save one function call for every token on the subject token stream whenever the macro pattern consists of a single parser */ $pattern = $cg->parsers[0]; } return $pattern; }
function hygienize(TokenStream $ts, string $scope) : TokenStream { $ts->reset(); traverse(either(chain(token(T_STRING, '·unsafe'), parentheses()), either(token(T_VARIABLE)->as('target'), chain(identifier()->as('target'), token(':')), chain(token(T_GOTO), identifier()->as('target')))->onCommit(function (Ast $result) use($scope) { (function () use($scope) { if ((string) $this !== '$this') { $this->value = (string) $this . '·' . $scope; } })->call($result->target); }), any()))->parse($ts); $ts->reset(); return $ts; }
function x2f($params, $confirm = false, $procedure = "in_controller__form_mail") { $formG = new FormGeneratorList($_POST); $file = get_w($params[0]); $option = get_w($params[1]); if (!$option) { $option = ""; } if (!$file or !file_exists(ROOT . "data/xml/{$file}.xml")) { exit; } $xml = simplexml_load_file(ROOT . "data/xml/{$file}.xml"); //setting $sendmail = $xml->sendmail == "yes"; $mailto = (string) $this->getOption($xml, "mailto", $option); $formG->title = (string) $this->getOption($xml, "title", $option); $formG->postTo = (string) $this->getOption($xml, "postback", $option); $formG->md5seed = (string) $this->getOption($xml, "md5seed", ""); if ((string) $this->getOption($xml, "confirm", "") == "yes") { $confirm = true; } $form = $xml->form; $counti = 1; foreach ($form->field as $field) { $field = (array) $field; $temp = array(); $temp["DISPLAY"] = $this->getOptionArr($field, "display", $option); $temp["NAME"] = either($field["name"], "formelement_" . $counti++); $html = $field["htmlgenerator"]; $classname = (string) $html->name; if ($classname == "HiddenGenerator") { $temp["HTML"] = new $classname(either((string) $html->param1, f($temp["NAME"]))); } else { $temp["HTML"] = new $classname((string) $html->param1, (string) $html->param2, (string) $html->param3); } $tempvalid = array(); foreach ($field["valids"] as $validitem) { $classname = (string) $validitem->name; $tempvalid[] = new $classname((string) $validitem->param1, (string) $validitem->param2, (string) $validitem->param3); } $temp["VALID"] = $tempvalid; $temp["ERROR"] = $this->getOptionArr($field, "error", $option); $formG->addGenerator($temp); } $ra_param = array(); $ra_param["sendmail"] = $sendmail; $ra_param["confirm"] = $confirm; echo $this->processForm($formG, $procedure, $ra_param); echo $this->htmlfooter(); exit; }
protected function preRender() { $this->begin($this->containerTag); $this->attr('id', either($this->props->containerId, $this->props->id)); $this->attr('class', enum(' ', rtrim($this->className, '_'), $this->props->class, $this->cssClassName, $this->props->disabled ? 'disabled' : null)); if (!empty($this->props->htmlAttrs)) { echo ' ' . $this->props->htmlAttrs; } if ($this->htmlAttrs) { foreach ($this->htmlAttrs as $k => $v) { echo " {$k}=\"" . htmlspecialchars($v) . '"'; } } }
/** * Returns the state of the player from the database, * uses a user_id if one is present, otherwise * defaults to the currently logged in player, but can act on any player * if another username is passed in. * @param $user user_id or username * @param @password Unless true, wipe the password. **/ function get_player_info($user = null, $password = false) { $sql = new DBAccess(); $player_data = null; if (is_numeric($user)) { $sel_player = "select * from players where player_id = '" . $user . "' limit 1"; } else { $username = either($user, SESSION::is_set('username') ? SESSION::get('username') : null); // Default to current session user. $sel_player = "select * from players where uname = '" . sql($username) . "' limit 1"; } $player_data = $sql->QueryRowAssoc($sel_player); if (!$password) { unset($player_data['pname']); } return $player_data; }
function index2($params) { $db = $this->fmodel('relation2'); $who = either(f('who'), 'root'); $this->sv('who', $who); $type = f('type'); if ($type == 'add') { $word2 = f('word2'); if ($word2) { $word2_array = explode(",", $word2); foreach ($word2_array as $j) { $db->save(array('word1' => $this->process_words(f('word1')), 'word2' => $this->process_words($j), 'relation' => f('relation'), 'who' => $who)); } } $this->to_path('?who=' . $who . '&type=relation&word=' . urlencode($this->process_words(f('word1')))); } $all = $db->peeks(array('who' => $who)); $level = count($all); $words = array(); foreach ($all as $i) { $words[] = $i['word1']; $words[] = $i['word2']; } $words = array_unique($words); sort($words); $this->sv('words', $words); $this->sv('all', $all); $this->sv('level', $this->levelstr($level)); if ($type == 'relation') { $frwords = array(); $brwords = array(); $word = f('word'); foreach ($all as $i) { if ($i['word1'] == $word) { $frwords[] = array('id' => $i['id'], 'word' => $i['word2'], 'relation' => str_replace(' ', ' ', e($i['relation']))); } if ($i['word2'] == $word) { $brwords[] = array('id' => $i['id'], 'word' => $i['word1'], 'relation' => str_replace(' ', ' ', e($i['relation']))); } } $frwords = array_unique($frwords); $brwords = array_unique($brwords); $this->sv('frwords', $frwords); $this->sv('brwords', $brwords); } }
function hygienize(TokenStream $ts, array $context) : TokenStream { $ts->reset(); $cg = (object) ['node' => null, 'context' => $context, 'ts' => $ts]; $saveNode = function (Parser $parser) use($cg) { return midrule(function ($ts) use($cg, $parser) { $cg->node = $ts->index(); return $parser->parse($ts); }); }; traverse(chain(token(T_STRING, '··unsafe'), either(parentheses(), braces())), either($saveNode(token(T_VARIABLE)), chain($saveNode(identifier()), token(':')), chain(token(T_GOTO), $saveNode(identifier())))->onCommit(function (Ast $result) use($cg) { if (($t = $cg->node->token) && ($value = (string) $t) !== '$this') { $cg->node->token = new Token($t->type(), "{$value}·{$cg->context['scope']}", $t->line()); } }))->parse($ts); $ts->reset(); return $ts; }
/** * Pull out the url for the player's avatar **/ function render_avatar($player, $size = null) { // If the avatar_type is 0, return ''; if (!$player->vo || !$player->vo->avatar_type || !$player->vo->email) { return ''; } else { // Otherwise, user the player info for creating a gravatar. $def = 'identicon'; // Default image or image class. // other options: wavatar , monsterid $email = $player->vo->email; $avatar_type = $player->vo->avatar_type; $base = "http://www.gravatar.com/avatar/"; $hash = md5(trim(strtolower($email))); $no_gravatar = "d=" . urlencode($def); $size = either($size, 80); $rating = "r=x"; $res = $base . $hash . "?" . implode("&", array($no_gravatar, $size, $rating)); return $res; } }
function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { $path = either($request->getAttribute('virtualUri', '<i>not set</i>'), '<i>empty</i>'); $realPath = $request->getUri()->getPath(); return Http::response($response, "<br><br><table align=center cellspacing=20 style='text-align:left'>\n<tr><th>Virtual URL:<td><kbd>{$path}</kbd>\n<tr><th>URL path:<td><kbd>{$realPath}</kbd>\n</table>", 'text/html', 404); }
$item = in('item'); $grammar = ""; $username = get_username(); $gold = either(getGold($username), 0); $current_item_cost = 0; $quantity = intval($in_quantity); if (!$quantity || $quantity < 1) { $quantity = 1; } else { if ($quantity > 1 && $item != "Shuriken") { $grammar = "s"; } } $item_costs = array("Speed Scroll" => 225, "Fire Scroll" => 175, "Stealth Scroll" => 150, "Ice Scroll" => 125, "Shuriken" => 50); if ($in_purchase == 1) { $current_item_cost = either($item_costs[$item], 0); $current_item_cost *= $quantity; if ($current_item_cost > $gold) { // Not enough gold. $description .= "<p>\"The total comes to {$current_item_cost} gold,\" the shopkeeper tells you.</p>"; $description .= "<p>Unfortunately, you do not have that much gold.</p>"; } else { // Has enough gold. addItem($username, $item, $quantity); $description .= "<p>The shopkeeper hands over {$quantity} " . $item . $grammar . ".</p>"; $description .= "<p>\"Will you be needing anything else today?\" he asks you as he puts your gold in a safe.</p>"; subtractGold($username, $current_item_cost); } } else { // Default, before anything has been bought. $description .= "<p>You enter the village shop and the shopkeeper greets you with a watchful eye.</p>";
function getMailStr() { $mailstr = ""; foreach ($this->list as $i) { $value = $this->valueS[$i["NAME"]]; $mailstr .= "<h3>" . either($i["DISPLAY"], $i["NAME"]) . "</h3>" . $i["HTML"]->getHTMLConfirm($i["NAME"], $value); $mailstr .= "<br>\n"; } return $mailstr; }
public function tesListingIsFillable() { $product = Factory::make('Giftertipster\\Entity\\Eloquent\\FeaturedListing'); assertThat($product['fillable'], either(hasItemInArray('listing'))->orElse(hasItemInArray('*'))); }
protected function render() { $prop = $this->props; $this->selIdx = $prop->selected_index; $pages = $this->getChildren('pages'); if (!empty($pages)) { //create data source for tabs from tab-pages defined on the source markup $data = []; /** @var TabPage $tabPage */ foreach ($pages as $idx => $tabPage) { $t = new TabsData(); $t->id = $tabPage->props->id; $t->value = either($tabPage->props->value, $idx); $t->label = $tabPage->props->label; $t->icon = $tabPage->props->icon; $t->inactive = $tabPage->hidden; $t->disabled = $tabPage->props->disabled; $t->url = $tabPage->props->url; $data[] = $t; } $propagateDataSource = false; } else { $data = $prop->data; $propagateDataSource = true; } if (!empty($data)) { $template = $prop->pageTemplate; if (isset($template)) { if (isset($pages)) { throw new ComponentException($this, "You may not define both the <b>p:page-template</b> and the <b>p:pages</p> parameters."); } $this->hasPages = true; } if ($propagateDataSource) { $this->viewModel = $data; } $value = either($prop->value, $this->selIdx); foreach ($data as $idx => $record) { if (!get($record, 'inactive')) { $isSel = get($record, $prop->valueField) === $value; if ($isSel) { $this->selIdx = $this->count; } ++$this->count; //create tab $tab = new Tab($this->context, ['id' => $prop->id . 'Tab' . $idx, 'name' => $prop->id, 'value' => get($record, $prop->valueField), 'label' => get($record, $prop->labelField), 'url' => get($record, 'url'), 'disabled' => get($record, 'disabled') || $prop->disabled, 'selected' => false], ['icon' => get($record, 'icon')]); $tab->container_id = $prop->id; $this->addChild($tab); //create tab-page $newTemplate = isset($template) ? clone $template : null; if (isset($template)) { $page = new TabPage($this->context, ['id' => get($record, 'id', $prop->id . 'Page' . $idx), 'label' => get($record, $prop->labelField), 'icon' => get($record, 'icon'), 'content' => $newTemplate, 'lazy_creation' => $prop->lazyCreation]); $newTemplate->attachTo($page); $this->addChild($page); } } } if (!empty($pages)) { $this->addChildren($pages); if ($this->selIdx >= 0) { $pages[$this->selIdx]->props->selected = true; } $this->setupSet($pages); $this->hasPages = true; } } //-------------------------------- $this->begin('fieldset', ['class' => enum(' ', 'tabGroup', $prop->tabAlign ? 'align_' . $prop->tabAlign : '')]); $this->beginContent(); $p = 0; if ($prop->tabAlign == 'right') { $selIdx = $this->count - $this->selIdx - 1; $children = $this->getChildren(); for ($i = count($children) - 1; $i >= 0; --$i) { $child = $children[$i]; if ($child->className == 'Tab') { $s = $selIdx == $p++; $child->props->selected = $s; if ($s) { $selName = $child->props->id; } $child->run(); } } } else { $selIdx = $this->selIdx; foreach ($this->getChildren() as $child) { if ($child->className == 'Tab') { $s = $selIdx == $p++; $child->props->selected = $s; if ($s) { $selName = $child->props->id; } $child->run(); } } } $this->end(); if ($this->hasPages) { $this->begin('div', ['id' => $prop->id . 'Pages', 'class' => enum(' ', 'TabsContainer', $prop->containerCssClass)]); $this->beginContent(); $p = 0; $selIdx = $this->selIdx; foreach ($this->getChildren() as $child) { if ($child->className == 'TabPage') { $s = $selIdx == $p++; $child->props->selected = $s; if ($s) { $sel = $child; } $child->run(); } } $this->end(); if (isset($sel)) { $this->tag('script', null, "Tab_change(\$f('{$selName}Field'),'{$this->props()->id}')"); } } }
public function testUpdatedAtIsGuarded() { $add_type = Factory::make('Giftertipster\\Entity\\Eloquent\\AddType'); assertThat($add_type['guarded'], either(hasItemInArray('updated_at'))->orElse(hasItemInArray('*'))); }
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();?><? include(GetLangFileName(dirname(__FILE__)."/", "/payment.php")); function either($a, $b) { if ($a != NULL) return $a; return $b;} $TMG_PK_SERVER_ADDR = CSalePaySystemAction::GetParamValue("TMG_PK_SERVER_ADDR"); $user_id = (int)$GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["USER_ID"]; $sum = (float)either( CSalePaySystemAction::GetParamValue("SHOULD_PAY"), $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"]); $orderid = (int)either( CSalePaySystemAction::GetParamValue("ORDER_ID"), $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"]); $email = either($GLOBALS["SALE_INPUT_PARAMS"]["PROPERTY"]["EMAIL"], $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["USER_EMAIL"]); $phone = htmlspecialchars($GLOBALS['SALE_INPUT_PARAMS']['PROPERTY']['PHONE']); // --- BEGIN --- костыль для arteva $arOrder = getOrder($orderid); $user_id = $arOrder["ACCOUNT_NUMBER"]; // вместо пользователя передаём номер заказа (не ID) // --- END --- $opts = array ("sum"=>$sum, "user_id"=>$user_id); $payment_parameters = array("clientid"=>$user_id, "orderid"=>$orderid, "sum"=>$sum, "phone"=>$phone, "email"=>$email); $query = http_build_query($payment_parameters); $err_num = $err_text = NULL; $form = QueryGetData($TMG_PK_SERVER_ADDR, 80, "/external/", $query, $err_num, $err_text); if ($form == "") $form = "<h3>Произошла ошибка при инциализации платежа</h3><p>$err_num: ".htmlspecialchars($err_text)."</p>";
public static function isAPI() { return either(self::$api, self::$qs[0] == 'API'); }
protected function render() { $prop = $this->props; $class = self::CSS_CLASS; $name = either($prop->name, $prop->id); $this->beginContent(); echo html([when(!str_endsWith($prop->name, '[]'), h('input', ['type' => 'checkbox', 'name' => $name, 'value' => '', 'checked' => true, 'style' => 'display:none'])), h('input', ['type' => 'checkbox', 'id' => $prop->id, 'name' => $name, 'class' => enum(' ', "{$class}-checkbox", "{$class}-" . ($prop->customColor ? substr($prop->customColor, 1) : $prop->color)), 'value' => $prop->value, 'checked' => $prop->checked || isset($prop->testValue) && $prop->value === $prop->testValue, 'disabled' => $prop->disabled, 'autofocus' => $prop->autofocus, 'onclick' => $prop->script]), h('label', ['for' => $prop->id, 'class' => "{$class}-label", 'data-off' => $prop->labelOff, 'data-on' => $prop->labelOn, 'title' => $prop->tooltip])]); }
public function testImageableTypeIsGuarded() { $product = Factory::make('Giftertipster\\Entity\\Eloquent\\Image'); assertThat($product['guarded'], either(hasItemInArray('imageable_type'))->orElse(hasItemInArray('*'))); }
private function mutate(TokenStream $ts, Ast $context) : TokenStream { $cg = (object) ['ts' => clone $ts, 'context' => $context]; if ($this->unsafe && !$this->hasTag('·unsafe')) { hygienize($cg->ts, $this->cycle->id()); } if ($this->constant) { return $cg->ts; } traverse(either(token(Token::CLOAKED), consume(chain(rtoken('/^·\\w+$/')->as('expander'), parentheses()->as('args')))->onCommit(function (Ast $result) use($cg) { $expander = $this->lookupExpander($result->expander); $args = []; foreach ($result->args as $arg) { if ($arg instanceof Token) { $key = (string) $arg; if (preg_match('/^·\\w+|T_\\w+·\\w+|···\\w+$/', $key)) { $arg = $cg->context->{$key}; } } if (is_array($arg)) { array_push($args, ...$arg); } else { $args[] = $arg; } } $mutation = $expander(TokenStream::fromSlice($args), $this->cycle->id()); $cg->ts->inject($mutation); }), consume(chain(rtoken('/^·\\w+|···\\w+$/')->as('label'), operator('···'), braces()->as('expansion')))->onCommit(function (Ast $result) use($cg) { $index = (string) $result->label; $context = $cg->context->{$index}; if ($context === null) { $this->fail(self::E_EXPANSION, $index, $result->label->line(), json_encode(array_keys($cg->context->all()[0]), self::PRETTY_PRINT)); } $expansion = TokenStream::fromSlice($result->expansion); // normalize single context if (array_values($context) !== $context) { $context = [$context]; } foreach (array_reverse($context) as $i => $subContext) { $mutation = $this->mutate($expansion, (new Ast(null, $subContext))->withParent($cg->context)); $cg->ts->inject($mutation); } }), consume(rtoken('/^(T_\\w+·\\w+|·\\w+|···\\w+)$/'))->onCommit(function (Ast $result) use($cg) { $expansion = $cg->context->{(string) $result->token()}; if ($expansion instanceof Token) { $cg->ts->inject(TokenStream::fromSequence($expansion)); } elseif (is_array($expansion) && \count($expansion)) { $tokens = []; array_walk_recursive($expansion, function (Token $token) use(&$tokens) { $tokens[] = $token; }); $cg->ts->inject(TokenStream::fromSlice($tokens)); } }), any()))->parse($cg->ts); $cg->ts->reset(); if ($this->cloaked) { traverse(either(consume(token(Token::CLOAKED))->onCommit(function (Ast $result) use($cg) { $cg->ts->inject(TokenStream::fromSourceWithoutOpenTag((string) $result->token())); }), any()))->parse($cg->ts); $cg->ts->reset(); } return $cg->ts; }
public function testUpdatedAtIsGuarded() { $product = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 1]); assertThat($product['guarded'], either(hasItemInArray('updated_at'))->orElse(hasItemInArray('*'))); }
private function mutate(TokenStream $ts, Ast $context, Cycle $cycle, Directives $directives, BlueContext $blueContext) : TokenStream { if ($this->constant) { return $ts; } static $states, $parser; $states = $states ?? new Stack(); $parser = $parser ?? traverse(token(Token::CLOAKED), consume(chain(rtoken('/^··\\w+$/')->as('expander'), either(parentheses(), braces())->as('args')))->onCommit(function (Ast $result) use($states) { $cg = $states->current(); $expander = $result->expander; if (\count($result->args) === 0) { $cg->this->fail(self::E_EMPTY_EXPANDER_SLICE, (string) $expander, $expander->line()); } $context = Map::fromKeysAndValues(['scope' => $cg->cycle->id(), 'directives' => $cg->directives, 'blueContext' => $cg->blueContext]); $expansion = TokenStream::fromSlice($result->args); $mutation = $cg->this->mutate(clone $expansion, $cg->context, $cg->cycle, $cg->directives, $cg->blueContext); $mutation = $cg->this->lookupExpander($expander)($mutation, $context); $cg->ts->inject($mutation); }), consume(chain(rtoken('/^·\\w+|···\\w+$/')->as('label'), operator('···'), optional(parentheses()->as('delimiters')), braces()->as('expansion')))->onCommit(function (Ast $result) use($states) { $cg = $states->current(); $context = $cg->this->lookupContext($result->label, $cg->context, self::E_UNDEFINED_EXPANSION); $expansion = TokenStream::fromSlice($result->expansion); $delimiters = $result->delimiters; // normalize single context if (array_values($context) !== $context) { $context = [$context]; } foreach (array_reverse($context) as $i => $subContext) { $mutation = $cg->this->mutate(clone $expansion, (new Ast(null, $subContext))->withParent($cg->context), $cg->cycle, $cg->directives, $cg->blueContext); if ($i !== 0) { foreach ($delimiters as $d) { $mutation->push($d); } } $cg->ts->inject($mutation); } }), consume(rtoken('/^(T_\\w+·\\w+|·\\w+|···\\w+)$/')->as('label'))->onCommit(function (Ast $result) use($states) { $cg = $states->current(); $context = $cg->this->lookupContext($result->label, $cg->context, self::E_UNDEFINED_EXPANSION); if ($context instanceof Token) { $cg->ts->inject(TokenStream::fromSequence($context)); } elseif (is_array($context) && \count($context)) { $tokens = []; array_walk_recursive($context, function (Token $token) use(&$tokens) { $tokens[] = $token; }); $cg->ts->inject(TokenStream::fromSlice($tokens)); } })); $cg = (object) ['ts' => $ts, 'context' => $context, 'directives' => $directives, 'cycle' => $cycle, 'this' => $this, 'blueContext' => $blueContext]; $states->push($cg); $parser->parse($cg->ts); $states->pop(); $cg->ts->reset(); if ($this->cloaked) { traverse(consume(token(Token::CLOAKED))->onCommit(function (Ast $result) use($cg) { $cg->ts->inject(TokenStream::fromSourceWithoutOpenTag((string) $result->token())); }))->parse($cg->ts); $cg->ts->reset(); } return $cg->ts; }
public function testUpdatedAtIsGuarded() { $product = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\SubInterestCategory'); assertThat($product['guarded'], either(hasItemInArray('updated_at'))->orElse(hasItemInArray('*'))); }
private function mail_me($title, $a, $file) { $this->load('lib/phpmailer/class.phpmailer'); $mail = new PHPMailer(); //$body = $mail->getFile(ROOT.'index.php'); //$body = eregi_replace("[\]",'',$body); $mail->IsSendmail(); // telling the class to use SendMail transport $mail->From = "*****@*****.**"; $mail->FromName = "Jim"; $mail->Subject = either($title, $_SERVER['REQUEST_URI']); $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($a); $mail->AddAddress($this->config["site"]["mail"], "SAMA"); if ($file) { foreach ($file as $i) { $mail->AddAttachment($i); // attachment } } if (!$mail->Send()) { return "Mailer Error: " . $mail->ErrorInfo; } else { return "Message sent!"; } }
die; } else { SESSION::set('recent_attack', $start_of_attack); } ?> <span class="brownHeading">Battle Status</span> <hr> <?php // TODO: Turn this page/system into an object to be run. // *** ********* GET VARS FROM POST - OR GET ************* *** $attacked = in('attacked'); // boolean for attacking again $target = $attackee = either(in('target'), in('attackee')); $username = get_username(); // Pulls from an internal source. $attacker = $username; // *** Target's stats. *** $attackee_health = getHealth($target); $attackee_level = getLevel($target); $attackee_str = getStrength($target); $attackee_status = getStatus($target); // *** Attacker's stats. *** $attacker_health = getHealth($username); $attacker_level = getLevel($username); $user_turns = getTurns($username); $attacker_str = getStrength($username); $attacker_status = getStatus($username); $class = getClass($username);
public function testUserIdIsFillable() { $product = Factory::make('Giftertipster\\Entity\\Eloquent\\ProductRequest'); assertThat($product['fillable'], either(hasItemInArray('user_id'))->orElse(hasItemInArray('*'))); }