/** * @param Processor $processor */ public function checkout(Processor $processor) { foreach ($this->getItems() as $item) { $processor->add($item->getPrice()); } $payment = $this->isCredit ? $this->factory->getCredit() : $this->factory->getCash(); $processor->pay($payment); }
/** * @dataProvider processors */ public function testProcessor($path, $data, $processors, $expected) { $processor = new Processor(); foreach ($processors as $callback) { $processor->add($callback); } $this->assertEquals($expected, $processor->process($path, $data)); }
public function testProcessCompletedSuccess() { $payuplOrderId = 'ABC'; $status = 'COMPLETED'; $amount = 2.22; $order = $this->getOrderMock(); $this->orderHelper->expects($this->once())->method('loadOrderByPayuplOrderId')->willReturn($order); $this->orderHelper->expects($this->once())->method('completePayment')->with($this->equalTo($order), $this->equalTo($amount)); $this->transactionService->expects($this->once())->method('updateStatus')->with($this->equalTo($payuplOrderId), $this->equalTo($status), $this->equalTo(true)); $this->model->processCompleted($payuplOrderId, $status, $amount); }
protected function applyChanges($version, $changes) { foreach ($changes as $file) { $this->output->notice('Applying changeset: ' . $this->versionPrefix . $version . '/' . $file); $this->processor->applyFile($this->changesetPath . '/' . $this->versionPrefix . $version . '/' . $file); $this->processor->metaChange('INSERT INTO _metaChange (name) VALUES (?)', $file); } }
/** * Get the processor with all default unserializer handlers in the API * @return Processor */ public static function getProcessor() { $instance = new Processor(); $instance->addUnserializerHandler(new Handler\Address()); $instance->addUnserializerHandler(new Handler\Amount()); $instance->addUnserializerHandler(new Handler\ArrayPaymentInstruments()); $instance->addUnserializerHandler(new Handler\Company()); $instance->addUnserializerHandler(new Handler\PaymentInstruments()); $instance->addUnserializerHandler(new Handler\Person()); return $instance; }
/** * @covers \CentralApps\Authentication\Processor::attemptToLogin * @covers \CentralApps\Authentication\Processor::authenticateFromUserId */ public function testLoggingIn() { $user = new \stdClass(); $user->userId = 1; $user_gateway = $this->getMock('\\CentralApps\\Authentication\\UserGateway'); $session_provider = $this->getMock('\\CentralApps\\Authentication\\Providers\\ProviderInterface'); $session_provider->expects($this->once())->method('hasAttemptedToLoginWithProvider')->will($this->returnValue(false)); $session_provider_2 = $this->getMock('\\CentralApps\\Authentication\\Providers\\ProviderInterface'); $session_provider_2->expects($this->once())->method('hasAttemptedToLoginWithProvider')->will($this->returnValue(true)); $session_provider_2->expects($this->once())->method('processLoginAttempt')->will($this->returnValue($user)); $this->_container->insert($session_provider, 10); $this->_container->insert($session_provider_2, 0); $settings_provider = $this->getMock('\\CentralApps\\Authentication\\SettingsProviderInterface'); $settings_provider->expects($this->once())->method('getUserGateway')->will($this->returnValue($user_gateway)); $processor = new Processor($settings_provider, $this->_container); $processor->attemptToLogin(); $this->assertTrue($processor->hasAttemptedToLogin(), "It doesn't look like we tried to login the user"); $this->assertEquals($user, $processor->getUser()); }
public static function __callStatic($sTemplate, $aArgs) { if ($aDirs = M::TEMPLATE_PHP()) { foreach ($aDirs as $sDir) { $sPath = M::PROJECT_ROOT() . '/' . $sDir . '/tpl.' . $sTemplate . '.php'; if (file_exists($sPath)) { self::_findJsFile($sTemplate); self::_findCssFile($sTemplate); if (isset($aArgs[0])) { print Processor::evalString(file_get_contents($sPath), $aArgs[0]); } return; } } } throw new Exception("Template \"{$sTemplate}\" is not found"); }
function __construct() { $posts = PostHelper::checkClean($_POST); self::$startDate = PostHelper::getStartDate($posts); self::$emails = PostHelper::getEmails($posts); self::$doEmployee10 = count(self::$emails) > 1 ? true : false; // echo '<pre>'; $submitType = PostHelper::getSubmitType($posts); switch ($submitType) { case "10-1": self::$events['ev10-1'] = self::setTen(1); case "10-2": self::$events['ev10-2'] = self::setTen(2); case "20": self::setIcs20($posts); } /*self::setIcs20($posts); self::$events['ev10-1'] = self::setTen(1); self::$events['ev10-2'] = self::setTen(2);*/ }
/** @inheritdoc */ public static function apply($name, $value, $modifierChain, $params = array()) { // Check if variable is of array type if (is_array($value)) { return 'Array'; } // Check if variable is not an object if (!is_object($value)) { return (string) $value; } // Fetch the modifier to apply on the value $nextModifier = array_shift($modifierChain); // Check if modifier is valid if ($nextModifier == '' && count($modifierChain) == 0) { return $value; } // Parse modifier parameter string list($modifierName, $modifierParams) = self::parseModifierParameterString($nextModifier); // Apply modifier on the value $value = self::calculateValue($modifierName, $modifierParams, $value, $params); // Do recursive call if there are more modifiers in the chain return count($modifierChain) > 0 ? Processor::applyModifier($value, $modifierChain, $params) : $value; }
<?php namespace OpenSslCrypt; set_include_path('../lib/' . PATH_SEPARATOR . get_include_path()); require_once 'OpenSslCrypt/Processor.php'; require_once 'OpenSslCrypt/Key/Pub.php'; require_once 'OpenSslCrypt/Key/Priv.php'; $data = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; printf("Data to encrypt: %s\n", $data); $processor = new Processor(); /* * Encryption with the public key. */ $pubKey = Key\Pub::fromCertificateFile('ssl/crypt.crt'); $encData = $processor->encrypt($data, $pubKey); printf("Encrypted data: %s\nEncryption key (encrypted): %s\n", $encData->getData(true), $encData->getKey(true)); /* * Decryption with the private key. */ $privKey = Key\Priv::fromPrivateKeyFile('ssl/crypt.key'); $decData = $processor->decrypt($encData, $privKey); printf("Decrypted data: %s\n", $decData);
$text = $_POST["text"]; //$text = array(); //$text[] = "カリン、自分でまいた種は自分で刈り取[qw]"; //$text[] = 'モーラ、モラ(mora)とは、音韻論上、一定の時間的長さをもった音の分節単位。古典詩における韻律用語であるラテン語のmŏra(モラ)の転用(日本語における「モーラ」という表記は英語からの音訳であり、「モラ」という表記はラテン語からの音訳)。拍(はく)と訳される。'; $type = 0; if ($_POST["dict"]) { $type |= Processor::Lemmas; } if ($_POST["rubies"]) { $type |= Processor::Rubies; } if ($_POST["full_reading"]) { $type |= Processor::FullReadings; } //$type = Processor::ReadingsAndLemmas; $proc = new Processor($type); $retv = array(); $sent = 0; foreach ($text as $v) { $proc->send_text($v); $sent++; if ($sent >= 3) { $retv[] = $proc->get_response(); $sent--; } } while ($sent) { $retv[] = $proc->get_response(); $sent--; } jexit(array("status" => "OK", "wall_time" => microtime(true) - $time_start, "cpu_time" => rutime(getrusage(), $ru_start, "utime"), "data" => $retv));
} if (isset($_GET['method'])) { $method = $_GET['method']; } if (isset($_GET['property'])) { $property = $_GET['property']; } require 'src/Block.php'; require 'src/ClassDesc.php'; require 'src/Constant.php'; require 'src/Method.php'; require 'src/Parameter.php'; require 'src/Property.php'; require 'src/ReturnType.php'; require 'src/Processor.php'; $data = new Processor(null, "../src/{$src}"); ?> <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>Phaser Documentation Viewer: <?php echo $src; ?> </title> <style type="text/css"> body { font-family: Arial; font-size: 14px; background-color: #fff; color: #000;
/** * Processes a positive authentication response. * * @param Boolean $valid True if the request has already been authenticated */ function processPositiveResponse($valid) { Logger::log('Positive response: identity = %s, expected = %s', $_REQUEST['openid_identity'], $_SESSION['openid']['claimedId']); if (!URLBuilder::isValidReturnToURL($_REQUEST['openid_return_to'])) { Logger::log('Return_to check failed: %s, URL: %s', $_REQUEST['openid_return_to'], URLBuilder::getCurrentURL(true)); error('diffreturnto', 'The identity provider stated return URL was ' . $_REQUEST['openid_return_to'] . ' but it actually seems to be ' . URLBuilder::getCurrentURL()); } $id = $_REQUEST[isset($_REQUEST['openid_claimed_id']) ? 'openid_claimed_id' : 'openid_identity']; if (!URLBuilder::isSameURL($id, $_SESSION['openid']['claimedId']) && !URLBuilder::isSameURL($id, $_SESSION['openid']['opLocalId'])) { if ($_SESSION['openid']['claimedId'] == 'http://specs.openid.net/auth/2.0/identifier_select') { $disc = new Discoverer($_REQUEST['openid_claimed_id'], false); if ($disc->hasServer($_SESSION['openid']['endpointUrl'])) { $_SESSION['openid']['identity'] = $_REQUEST['openid_identity']; $_SESSION['openid']['opLocalId'] = $_REQUEST['openid_claimed_id']; } else { error('diffid', 'The OP at ' . $_SESSION['openid']['endpointUrl'] . ' is attmpting to claim ' . $_REQUEST['openid_claimed_id'] . ' but ' . ($disc->getEndpointUrl() == null ? 'that isn\'t a valid identifier' : 'that identifier only authorises ' . $disc->getEndpointUrl())); } } else { error('diffid', 'Identity provider validated wrong identity. Expected it to ' . 'validate ' . $_SESSION['openid']['claimedId'] . ' but it ' . 'validated ' . $id); } } resetRequests(true); if (!$valid) { $dumbauth = true; if (KEYMANAGER) { try { Logger::log('Attempting to authenticate using association...'); $valid = KeyManager::authenticate($_SESSION['openid']['endpointUrl'], $_REQUEST); $dumbauth = false; } catch (Exception $ex) { // Ignore it - try dumb auth } } if ($dumbauth) { Logger::log('Attempting to authenticate using dumb auth...'); $valid = KeyManager::dumbAuthenticate(); } } $_SESSION['openid']['validated'] = $valid; if (!$valid) { Logger::log('Validation failed!'); error('noauth', 'Provider didn\'t authenticate response'); } Processor::callHandlers(); URLBuilder::redirect(); }
<?php require 'src/Block.php'; require 'src/ClassDesc.php'; require 'src/Constant.php'; require 'src/Method.php'; require 'src/Parameter.php'; require 'src/Property.php'; require 'src/ReturnType.php'; require 'src/Processor.php'; // $data = new Processor("../src/gameobjects/Sprite.js"); $data = new Processor("../src/loader/Cache.js"); header('Content-Type: application/json'); $raw = []; $raw['consts'] = $data->getConstsArray(); echo json_encode($raw); // echo $data->consts[0]->getJSON();
/** @inheritdoc */ public static function calculateValue($modifierName, $modifierParams, $value, $params = array()) { switch ($modifierName) { case "ifnotempty": case "stopifempty": if (count($value) == 0) { return ""; } break; case "ifempty": case "stopifnotempty": $default = Util::lavnn('default', $modifierParams, ''); if (count($value) != 0) { return ""; } elseif ($default != '') { return $default; } break; case "length": $value = count($value); break; case "first": $value = $value[0]; break; case "last": $value = $value[count($value)]; break; case "field": $fieldName = Util::lavnn('name', $modifierParams, ''); $value = Util::lavnn($fieldName, $value, ''); break; case "buildquerystring": $value = '?' . http_build_query($value); break; case "cutcolumn": $columnName = Util::lavnn('column', $params, ''); $output = array(); foreach ($value as $row) { $columnValue = Util::lavnn($columnName, $row, ''); if ($columnValue != '') { $output[$columnValue] = $columnValue; } } $value = $output; break; case "join": $glue = Util::lavnn('glue', $modifierParams, ''); $value = join(Processor::glueDecoder($glue), $value); break; case "joincolumn": $fieldName = Util::lavnn('field', $modifierParams, ''); $glue = Util::lavnn('glue', $modifierParams, ''); $rowValues = array(); foreach ($value as $row) { $fieldValue = $row[$fieldName] or ''; if ($fieldValue != '') { $rowValues[] = $row[$fieldName]; } } $value = join(Processor::glueDecoder($glue), $rowValues); break; case 'replace': $default = Util::lavnn('default', $modifierParams, ''); $fallback = Util::lavnn('fallback', $modifierParams, ''); $value = Util::lavnn($fallback, $params, $default); break; case "ksort": ksort($value); break; case "asort": asort($value); break; case "sort": sort($value); break; case "json": $value = json_encode($value); break; default: $value = parent::calculateValue($modifierName, $modifierParams, $value, $params); break; } return $value; }
<?php /** * Processor runner */ namespace processor; include_once '../app/autoloader.php'; $processor = new Processor(); $processor->run();
public static function register($bot, $name, $registerable) { return parent::register($bot, $name, $registerable); }
/** @inheritdoc */ public static function calculateValue($modifierName, $modifierParams, $value, $params = array()) { switch ($modifierName) { case 'tag': return '{{' . $value . '}}'; break; case "lowercase": $value = strtolower($value); break; case "uppercase": $value = strtoupper($value); break; case "trim": $value = trim($value); break; case "length": $value = strlen($value); break; case "wordcount": //$value = str_word_count($value, 0, '/[\p{C}\p{S}\p{Z}]+/'); // does not work with utf-8 $value = str_replace("", '', $value); // soft hyphen encoded in UTF-8 $value = preg_match_all('~[\\p{L}\'\\-]+~u', $value); break; case "htmlentities": $value = htmlentities($value); break; case "zero": if ($value == '') { $value = 0; } break; case "shortener": $wordCount = Util::lavnn('words', $modifierParams, 0); $charCount = Util::lavnn('chars', $modifierParams, 0); $value = TextUtil::shorten($value, $wordCount, $charCount); break; case "split": $delimiter = Util::lavnn('delimiter', $modifierParams, ''); $value = explode(Processor::glueDecoder($delimiter), $value); break; case "if": if (!self::applyIf($modifierParams, $value, $params)) { return ''; } break; case "ifempty": $default = Util::lavnn('default', $modifierParams, ''); $fallback = Util::lavnn('fallback', $modifierParams, ''); if ($value != '') { return $value; } elseif ($fallback != '') { // @TODO fallback is now on top level of $params. make it findable in the tree return Util::lavnn($fallback, $params, $default); } else { return $default; } break; case "ifnotempty": if (is_null($value) || $value == '') { return ''; } break; case 'replace': $default = Util::lavnn('default', $modifierParams, ''); $fallback = Util::lavnn('fallback', $modifierParams, ''); $value = $fallback == '' ? $default : Util::lavnn($fallback, $params, $default); break; case "dbsafe": $value = TextUtil::dbsafe($value); break; case "jssafe": $value = TextUtil::jssafe($value); break; case "htmlsafe": $value = TextUtil::htmlsafe($value); break; case "urlencode": $value = urlencode($value); break; case "fixfloat": $value = floatval($value); break; case "fixint": $value = intval($value); break; case "fixbool": $value = (bool) $value; break; case 'rsstime': $value = date('D, d M Y H:i:s O', strtotime($value)); break; case 'dbdate': // Convert date from current locale format to DB-suitable format if ($value != '') { $value = DateTimeUtil::DateTimeToDB($value, Util::lavnn('time', $modifierParams, 'now')); } break; case 'date': // Convert database-formatted datetime into user favourite locale, without time if ($value != '') { $utcDate = date_create_from_format('Y-m-d H:i:s', $value); if (!$utcDate) { $value = date($_SESSION['formats']['date_php'], strtotime($value)); } else { $offset = Util::lavnn('timezoneOffset', $_SESSION, 0); $localDate = $utcDate->modify("+{$offset} minutes"); // fixing the timezone offset can change the date $value = $localDate->format($_SESSION['formats']['date_php']); } } break; case 'time': // Convert database-formatted datetime into user favourite locale, without date if ($value != '') { $utcDate = date_create_from_format('Y-m-d H:i:s', $value); if (!$utcDate) { $value = date($_SESSION['formats']['time_php'], strtotime($value)); } else { $offset = Util::lavnn('timezoneOffset', $_SESSION, 0); $localDate = $utcDate->modify("+{$offset} minutes"); $value = $localDate->format($_SESSION['formats']['time_php']); } } break; case 'datetime': // Convert database-formatted datetime into user current locale, using time if ($value != '') { $utcDate = date_create_from_format('Y-m-d H:i:s', $value); if (!$utcDate) { $value = date($_SESSION['formats']['datetime_php'], strtotime($value)); } else { $offset = Util::lavnn('timezoneOffset', $_SESSION, 0); $localDate = $utcDate->modify("+{$offset} minutes"); $value = $localDate->format($_SESSION['formats']['datetime_php']); } } break; case 'timestamp': if ($value != '') { $value = strtotime($value); } break; case "fixurl": $value = $value == '' ? '#' : (substr($value, 0, 4) != 'http' ? 'http://' : '') . $value; break; case "nohtml": $value = strip_tags($value); break; case "htmlcomment": $value = "<!--{$value}-->"; break; case "dump": $value = print_r($value, 1); break; case 'unserialize': $value = $value == '' ? array() : json_decode($value, true); break; case 'loremipsum': $loremIpsum = array("Donec ullamcorper nulla non metus auctor fringilla.", "Vestibulum id ligula porta felis euismod semper.", "Praesent commodo cursus magna, vel scelerisque nisl consectetur.", "Fusce dapibus, tellus ac cursus commodo."); $value = $value == '' ? join(' ', $loremIpsum) : $value; break; case 'gravatar': $size = Util::lavnn('size', $modifierParams, 50); $email = md5(strtolower(trim($value))); $value = "http://www.gravatar.com/avatar/{$email}?s=" . $size; break; default: $value = parent::calculateValue($modifierName, $modifierParams, $value, $params); break; } return $value; }
/** * @param Processor $processor */ public function addProcessor(Processor $processor) { $this->processors[$processor->getName()] = $processor; }
$requiredConfigs = array($config); CheckConfig::configs($requiredConfigs); require_once $config; $requiredExtensions = array("mbstring", "pcre", "PDO"); CheckConfig::extensions($requiredExtensions); mb_internal_encoding("UTF-8"); Options::setDebug(DEBUG || array_search("--debug", $argv)); Options::setPretend(array_search("--pretend", $argv)); Options::setVerbose(Options::debug() || Options::pretend() || array_search("--verbose", $argv)); Log::open(__FILE__, true, Options::verbose(), Options::debug()); Log::notice(sprintf("Running '%s'...", implode(" ", $argv))); $monitor = Monitor::create(dirname(__FILE__) . "/monitor"); if ($monitor !== false) { $sources = $monitor->getEnabledSources(); $dbh = new DBH(DBDSN, DBUSER, DBPASS); $processor = new Processor($dbh); foreach ($sources as $source) { $processor->process($monitor, $source); } $processor->discard(EVENT_DISCARD_THRESHOLD); $status = 0; } else { $status = 1; } } catch (Exception $e) { Log::err(sprintf("Log file processing failed with exception: %s\nDetails: %s", $e->getMessage(), $e)); $status = 1; } if (isset($dbh)) { $dbh->close(); }
public function process(\AMQPEnvelope $message) { parent::process($message); echo 'BAR:' . $message->getBody() . "\n"; return "test-response2"; }
public static function send($sContent, $bEval = true) { self::$_sCurrentFileName = ''; if ($bEval) { print Processor::evalString($sContent); } else { print $sContent; } self::$_bReadyToSend = true; }
*/ protected $publisher; public function setPublisher(\Amqp\Util\Publisher\Interfaces\Publisher $publisher) { $this->publisher = $publisher; } public function process(\AMQPEnvelope $msg) { echo date("Y-m-d H:i:s") . " Received message!\n"; return false; } } // retrieve the exchange. this will trigger all other exchanges to get declared $exchange = $builder->exchange('main_exchange'); // retrieve the queue. This will trigger all other queues to be declared $queue = $builder->queue('main_queue'); // retrieve the final exchange for publishing $rejectExchange = $builder->exchange($config['reject_target_exchange']); $publisher = new \Amqp\Util\Publisher\Simple(); $publisher->setExchange($exchange); $processor = new Processor(); $processor->setPublisher($publisher); $simpleListener = new \Amqp\Util\Listener\Simple(); $simpleListener->setQueue($queue); $simpleListener->setConfiguration($config); $simpleListener->setProcessor($processor); $simpleListener->setBuilder($builder); // use without a builder //$simpleListener->setRejectTarget($rejectExchange, $config['reject_target_routingKey']); echo date("Y-m-d H:i:s") . " Started listener for test!\n"; $simpleListener->listen();
<?php require 'postHelper.php'; require 'icsGenerator.php'; require 'emailHelper.php'; require 'eventData.php'; //header('HTTP/1.0 200 OK', true, 200); //echo '<pre>'; //var_dump($_POST);exit; date_default_timezone_set('America/New_York'); /*echo '<br>'; var_dump(date('h:i:s A')); echo date_default_timezone_get(); exit;*/ $process = new Processor(); //$process->mailAll(); $process->mailSingle(); header('HTTP/1.0 200 OK', true, 200); /*if(isset($_POST['startDate'])){ $process = new Processor(); if(isset($_POST['action'])){ $act = $_POST['action']; switch($act){*/ //case 'mail10': /** Create and Email 10 ICSs **/ /*$process->mail10(); break; case '10:1': /** Create and Download ICS 10 #1**/ /* $process->ouput10(1); break; case '10:2': /** Create and Download ICS 10 #1**/ /* $process->ouput10(1);
define('GZIP', 'gzip -cn6 %1$s > %1$s.gz'); function error400($error = 'Invalid formula') { header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request'); include '400.php'; } //ignore_user_abort(); ini_set('max_execution_time', 10); header('X-Powered-By: S2 Latex Service'); $templater = new Templater(TPL_DIR); $renderer = new Renderer($templater, TMP_DIR, LATEX_COMMAND, DVISVG_COMMAND, DVIPNG_COMMAND); if (defined('LOG_DIR')) { $renderer->setLogDir(LOG_DIR); } $renderer->setDebug($isDebug); $processor = new Processor($renderer, CACHE_SUCCESS_DIR, CACHE_FAIL_DIR); $processor->addSVGCommand(SVGO); $processor->addSVGCommand(GZIP); try { $processor->parseURI(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); } catch (Exception $e) { error400($isDebug ? $e->getMessage() : 'Invalid formula'); die; } if ($processor->prepareContent()) { $processor->echoContent(); } else { error400($isDebug ? $processor->getError() : 'Invalid formula'); } if (!$isDebug) { $processor->saveContent();
public function respond() { return parent::respond(); }
background-color: #fff; color: #000; } textarea { width: 100%; height: 1000px; } </style> </head> <body> <pre spellcheck="false"> <?php // $data = new Processor("../src/gameobjects/Sprite.js"); $data = new Processor("../src/loader/Cache.js"); echo $data->total() . " blocks found\n\n"; /* echo "\nConstants:\n\n"; for ($i = 0; $i < count($data->consts); $i++) { // print_r($data->consts[$i]->getJSON()); $const = $data->consts[$i]; echo "\n\n"; echo $const->name; echo "\n"; print_r($const->types); } */ echo "\nMethods:\n\n";