function process($s) { $bidx = strpos($s, '('); while ($bidx !== FALSE) { $count = 1; $eidx = $bidx + 1; for (; $count; $eidx++) { if ($s[$eidx] == '(') { $count++; } if ($s[$eidx] == ')') { $count--; } } $s = substr($s, 0, $bidx) . process(substr($s, $bidx + 1, $eidx - 1 - ($bidx + 1))) . substr($s, $eidx); $bidx = strpos($s, '('); } $matches = null; while (preg_match("/^(.*?)(-?\\d+)([*\\/])(-?\\d+)(.*)\$/", $s, $matches)) { if ($matches[3] == '*') { $s = $matches[1] . $matches[2] * $matches[4] . $matches[5]; } else { $s = $matches[1] . intval($matches[2] / $matches[4]) . $matches[5]; } } while (preg_match("/^(.*?)(-?\\d+)([+Z])(-?\\d+)(.*)\$/", $s, $matches)) { if ($matches[3] == '+') { $s = $matches[1] . ($matches[2] + $matches[4]) . $matches[5]; } else { $s = $matches[1] . ($matches[2] - $matches[4]) . $matches[5]; } } return $s; }
function process(DOMNode $current_node) { global $filter_args, $filter_tags, $filter_mandatory, $bbcode; if ($current_node instanceof DOMElement || $current_node instanceof DOMDocument) { // Recursion. I need iterator_to_array(), because it's likely // that node list will be modified. foreach (iterator_to_array($current_node->childNodes) as $node) { process($node); } // BBCode hack is NOT allowed to exist if ($current_node->tagName === 'bbcodehack') { $value = $current_node->hasAttribute('value') ? $current_node->getAttribute('value') : NULL; $nodes = $current_node->hasAttribute('pre') ? $current_node->getAttribute('pre') : $current_node->childNodes; $nodes = $bbcode[$current_node->getAttribute('name')]['callback']($current_node->ownerDocument, $nodes, $value, array('borked' => $current_node->hasAttribute('borked'))); if (!is_array($nodes)) { $nodes = array($nodes); } foreach ($nodes as $node) { $current_node->parentNode->insertBefore($node, $current_node); } // Remove bbcodehack from DOM $current_node->parentNode->removeChild($current_node); } elseif ($current_node->tagName && !isset($filter_tags[$current_node->tagName])) { while ($current_node->hasChildNodes()) { $current_node->parentNode->insertBefore($current_node->childNodes->item(0), $current_node); } $current_node->parentNode->removeChild($current_node); } else { if ($current_node->hasAttributes()) { // I need iterator_to_array, as I modify attributes // list while iterating. foreach (iterator_to_array($current_node->attributes) as $attr) { $attribute = isset($filter_tags[$current_node->tagName][$attr->name]) ? $filter_tags[$current_node->tagName][$attr->name] : (isset($filter_args[$attr->name]) ? $filter_args[$attr->name] : NULL); if (!$attribute) { $current_node->removeAttribute($attr->name); } elseif (!is_bool($attribute)) { $value = $attribute($attr->value, $current_node); if ($value === NULL) { $current_node->removeAttribute($attr->name); } else { $current_node->setAttribute($attr->name, $value); } } } } if (isset($filter_mandatory[$current_node->tagName])) { foreach ($filter_mandatory[$current_node->tagName] as $attr => $value) { if (!$current_node->hasAttribute($attr)) { $current_node->setAttribute($attr, $value); } } } } } elseif ($current_node instanceof DOMComment) { // Unsafe because of conditional comments $current_node->parentNode->removeChild($current_node); } }
function process(\CompositeElement $elementObject, $level) { $level++; echo $level . ': ' . $elementObject . '<br/>'; if (count($elementObject) > 0) { foreach ($elementObject as $elementChildObject) { process($elementChildObject, $level); } } }
function process(&$inputs, $length, $total, &$count, &$ways, $i = 0, $number = 0) { if ($total == 0) { return $count++ && ($ways[$number] = isset($ways[$number]) ? $ways[$number] + 1 : 1); } if ($i >= $length || $total < 0) { return; } process($inputs, $length, $total - $inputs[$i], $count, $ways, $i + 1, $number + 1); process($inputs, $length, $total, $count, $ways, $i + 1, $number); }
function input() { #Prompt user if (PHP_OS == 'WINNT') { echo "> "; $line = stream_get_line(STDIN, 1024, PHP_EOL); } else { $line = readline("> "); } #Pass input to switch function process($line); }
function process($input) { foreach ($input as &$item) { if (is_object($input) && is_string($item) && $item == "red") { return null; } if (is_object($item) || is_array($item)) { $item = process($item, is_object($item)); } } return $input; }
function process($data) { global $val; if (is_object($data) || is_array($data)) { foreach ($data as $datum) { process($datum); } } else { if (is_integer($data)) { $val += $data; } } }
function process($commit) { global $commits, $ordered; if (!count($commits[$commit]['parents'])) { $ordered[] = $commits[$commit]['commit']; foreach ($commits[$commit]['children'] as $child) { $commits[$child]['parents'] = array_filter($commits[$child]['parents'], function ($parent) use($commit) { return $parent !== $commit; }); process($child); } } }
function process($matches, $n, &$results = [], $calTot = null, $cap = 0, $dur = 0, $fla = 0, $tex = 0, $cal = 0) { $a = array_pop($matches); if (!count($matches)) { if (null == $calTot || $calTot == $cal + $n * $a[5]) { return $results[] = r($cap, $a[1], $n) * r($dur, $a[2], $n) * r($fla, $a[3], $n) * r($tex, $a[4], $n); } else { return; } } for ($i = 1; $i < $n; $i++) { process($matches, $n - $i, $results, $calTot, $cap + $i * $a[1], $dur + $i * $a[2], $fla + $i * $a[3], $tex + $i * $a[4], $cal + $i * $a[5]); } }
function process($replacements, $med, $current, &$results, $step = 0) { foreach ($replacements as $r) { if (($pos = strpos($med, $r[2])) !== false && ($cur = substr_replace($med, $r[1], $pos, strlen($r[2])))) { if ($cur == $current) { return $results[$step + 1] = 0; } if (strlen($cur) < 1) { continue; } return process($replacements, $cur, $current, $results, $step + 1); } } }
function process($base, $array) { $principal = function ($internalBase, $internalValue) { $pathBuffer = $internalBase . $internalValue . '/development/'; $styleBuffer = minify($pathBuffer); echo $pathBuffer; $pathFile = $internalBase . $internalValue . '/output/import-' . $internalValue . '.min.css'; writting($pathFile, $styleBuffer); }; foreach ($array as $key => $value) { if (!is_array($value)) { $principal($base, $value); } else { $principal($base, $key); process($base . $key . '/', $value); } } }
function search($expression, $from, $count, $lang) { global $applServer, $output; $from = $from != "" ? $from : "1"; $count = $count != "" ? $count : "10"; if ($lang == "es") { $iahLang = "e"; } else { if ($lang == "en") { $iahLang = "i"; } else { $iahLang = "p"; } } $serviceUrl = "http://" . $applServer . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^dlibrary&exprSearch=" . $expression . "&lang=" . $iahLang . "&nextAction=xml&isisFrom=" . $from . "&count=" . $count . "&fmt=citation"; $redirectHtml = "http://" . $applServer . "/cgi-bin/wxis.exe/iah/?IsisScript=iah/iah.xis&base=article^dlibrary&exprSearch=" . $expression . "&lang=" . $iahLang . "&nextAction=lnk&isisFrom=" . $from . "&count=" . $count; $response = process($serviceUrl, $redirectHtml); return $response; }
function process($nid, &$pages, &$obj, &$counters) { $incremented = array(); foreach ($pages[$nid] as $o) { $type = $o["#type"]; if ($type == "link") { process($o["#link"], $pages, $obj, $counters); continue; } $objProps = $obj[$type]; $counter = $lowest = $objProps["#counter"]; $fixed = $objProps["#fixed"]; if (!$fixed) { if (!isset($incremented[$counter])) { $last = $lowest = $counter; for (; $lowest != null && $counters[$lowest]["value"] == 0; $lowest = $counters[$lowest]["parent"]) { $last = $lowest; } $lowest = $last; $incremented[$counter] = array("#level" => $lowest); } else { $lowest = $incremented[$counter]["#level"]; } } if (isset($counters[$lowest]["children"])) { if (!isset($history)) { $history = array_merge(array(), $counters); } foreach ($counters[$lowest]["children"] as $child) { $counters[$child]["value"] = 0; } } $counters[$lowest]["value"]++; echo getLabel($counters, $lowest) . " - " . $o["#title"] . "<br/>"; } foreach ($incremented as $key => $val) { $lowest = $val["#level"]; $counters[$lowest]["value"] = 0; } if (isset($history)) { $counters = $history; } }
function process($places, $route = array(), $total = 0) { global $all, $nodes, $min, $minroute, $max, $maxroute; foreach ($places as $place => $distance) { if (count($route) == $all) { if ($min > $total) { $minroute = $route; $min = $total; } else { if ($max < $total) { $maxroute = $route; $max = $total; } } return; } if (in_array($place, $route)) { continue; } process($nodes[$place], array_merge($route, array($place)), $total + $distance); } }
function FT_load() { $config = (require_once PATH_APPLICATION . '/config/init.php'); autoDeleteFile(); $arrayUrl = parseUrl(); if (!empty($_SESSION['name'])) { process(); } else { if (!empty($_COOKIE['name'])) { $_SESSION['name'] = $_COOKIE['name']; $_SESSION['id'] = $_COOKIE['id']; $_SESSION['avatar'] = $_COOKIE['avatar']; } else { if ($arrayUrl[0] == 'user' && $arrayUrl[1] == 'login') { $controllerObject = new User_Controller(); $controllerObject->login(); } else { headerUrl('/user/login'); } } } }
function check() { $dmenu = def_menu(); $menu = array('Home' => array('Home' => ''), 'Account' => array('Rewards' => 'mpayouts', 'Payments' => 'payments', 'Settings' => 'settings', 'User Settings' => 'userset', '2FA Settings' => '2fa'), 'Workers' => array('Shifts' => 'shifts', 'Shift Graph' => 'usperf', 'Workers' => 'workers', 'Management' => 'workmgt'), 'Pool' => array('Stats' => 'stats', 'Blocks' => 'blocks', 'Graph' => 'psperf', 'Acclaim' => 'userinfo', 'Luck' => 'luck'), 'Admin' => NULL, 'gap' => array('API' => 'api', 'PBlocks' => 'pblocks'), 'Help' => array('Payouts' => 'payout')); tryLogInOut(); $who = loggedIn(); if ($who === false) { $p = getparam('k', true); if ($p == 'reset') { showPage(NULL, 'reset', $dmenu, '', $who); } else { if (requestLoginRegReset() == true) { showPage(NULL, 'reg', $dmenu, '', $who); } else { $p = getparam('k', true); process($p, $who, $dmenu); } } } else { $p = getparam('k', true); process($p, $who, $menu); } }
require_once __DIR__ . "/../../../vendor/autoload.php"; $DB = Database::singleton(); // Get the ID for the instrument that was selected $instrumentID = $_REQUEST['instrument']; $quizCorrect = markQuiz($instrumentID); if ($quizCorrect == false) { print "incorrect"; exit; } else { $user = User::singleton(); $userFullName = $user->getFullname(); $userCenter = $user->getCenterID(); $examinerID = $DB->pselectOne("SELECT examinerID \n FROM examiners\n WHERE full_name=:FN AND centerID=:CID", array('FN' => $userFullName, 'CID' => $userCenter)); $dateArray = array('Y' => date('Y'), 'M' => date('m'), 'd' => date('d')); $values = array('pass' => array($instrumentID => 'certified'), 'date_cert' => array($instrumentID => $dateArray), 'examiner' => $examinerID); process($values); print "correct"; exit; } /** * Determines if an answer is correct for a question from the training quiz * * @param string $instrumentID The ID of the instrument * @param string $question The question number * @param string $answer The answer number provided by the user * * @return int */ function correct($instrumentID, $question, $answer) { $DB = Database::singleton();
<?php $method = $_SERVER['REQUEST_METHOD']; switch ($method) { case 'POST': $request = $_POST; $result = process($request); echo json_encode($result); break; case 'GET': //process($request); break; case 'PUT': //do_something_with_put($request); break; case 'HEAD': //do_something_with_head($request); break; case 'DELETE': //do_something_with_delete($request); break; case 'OPTIONS': //do_something_with_options($request); break; default: //handle_error($request); break; } function process($data) { $result = ValidateKey($data);
#!/usr/bin/env php <?php /** * This file is part of Slicer. * * Copyright (c) 2015 Tom Kaczocha <*****@*****.**> * * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, you can obtain one at http://mozilla.org/MPL/2.0/. * * PHP version 5.6 */ process(is_array($argv) ? $argv : []); function process($argv) { $check = in_array('--check', $argv); $help = in_array('--help', $argv); $force = in_array('--force', $argv); $quiet = in_array('--quiet', $argv); $disableTls = in_array('--disable-tls', $argv); $installDir = FALSE; $version = FALSE; $filename = 'slicer.phar'; $cafile = FALSE; // --no-ansi wins over --ansi if (in_array('--no-ansi', $argv)) { define('USE_ANSI', FALSE); } elseif (in_array('--ansi', $argv)) { define('USE_ANSI', TRUE); } else {
if ($client < 0) { console("socket_accept() failed"); continue; } else { connect($client); } } else { $bytes = @socket_recv($socket, $buffer, 2048, 0); if ($bytes == 0) { disconnect($socket); } else { $user = getuserbysocket($socket); if (!$user->handshake) { dohandshake($user, $buffer); } else { process($user, $buffer); } } } } } //--------------------------------------------------------------- function process($user, $msg) { $action = unwrap($msg); say("< " . $action); switch ($action) { case "hello": send($user->socket, "hello human"); break; case "hi":
<?php $input = file('input'); echo process($input), ' ', process($input, 1); function process($input, $a = 0) { for ($i = 0, $c = count($input), $b = 0; $i < $c; $i++) { $instr = substr($input[$i], 0, 3); $split = explode(',', substr($input[$i], 4)); $r = trim($split[0]); $val = isset($split[1]) ? trim($split[1]) : null; if ($instr == 'hlf') { ${$r} /= 2; } elseif ($instr == 'tpl') { ${$r} *= 3; } elseif ($instr == 'inc') { ${$r}++; } elseif ($instr == 'jmp') { $i += $r - 1; } elseif ($instr == 'jie' && ${$r} % 2 == 0) { $i += $val - 1; } elseif ($instr == 'jio' && ${$r} == 1) { $i += $val - 1; } } return $b; }
$input = '1321131112'; function process($string) { $i = 1; $total = strlen($string); $digits = str_split($string); $current = false; $count = false; $output = false; foreach ($digits as $d) { $last = $i === $total; if ($current !== $d) { if ($current) { $output .= $count . $current; } $current = $d; $count = 1; } else { $count++; } if ($last) { $output .= $count . $current; } $i++; } return $output; } for ($i = 0; $i < 50; $i++) { $input = process($input); } var_dump($input);
$select = QueryFactory::Build("select"); $select->Select("name", "frequency", "lastRun")->From("schedule"); $res = DatabaseManager::Query($select); $res2 = $res->Result(); //fclose($myfile);//----------------------------- // iterate through each task and proccess if ($res->RowCount() > 1) { // fwrite($myfile, "in first if\n");//------------------------ foreach ($res2 as $curr) { // fwrite($myfile,"prosess\n");//-------------------------------- process($curr); } } else { if ($res->RowCount() == 1) { // fwrite($myfile ,"other prosess\n");//--------------------------------------- process($res2); } } //fclose($myfile); function process($curr) { echo $curr["name"] . ": "; echo $curr["frequency"] . "<br>"; //if need to run task if (strtotime($curr["frequency"], $curr["lastRun"]) < time()) { //run job include __DIR__ . '/' . $curr["name"]; //update last run time $ran = QueryFactory::Build('update'); $ran->Table("schedule")->Set(["lastRun", time()])->Where(["name", '=', $curr["name"]]); $success = DatabaseManager::Query($ran);
<?php @($demoScenario = array()); @($enable_logging = true); @($logging_db = array("host" => "localhost:3306", "user" => "beacondemo", "pass" => "HhNMCX6mqQZPP3PW")); // on GERSASCI: hKByMym2E9eKeV2F if ($_SERVER['REQUEST_METHOD'] == "GET") { @($action = $_GET['action']); @($param = $_GET['param']); } else { @($action = $_POST['action']); @($param = $_POST['param']); } session_set_cookie_params(3600 * 24 * 30); session_start(); process($action, $param); return; function process($action, $param) { if ($action == 'reset') { session_destroy(); header('Location:' . $_SERVER['PHP_SELF']); return true; } else { if ($action == 'saveScenario') { @header('Content-type: application/json'); @logUsage("DEMO_SAVE", $param, "", ""); return true; } else { @header('Content-type: application/json'); @logUsage("DEMO_LOADING", $param, "", "");
function process($json, $xml = null) { if (isset($json->attributes)) { foreach ($json->attributes as $key => $val) { $name = $key; //echo $name; $value = $val; //echo $value; if (is_null($xml)) { if ($name == 'nodeName') { $xml = new ExSimpleXMLElement('<' . $value . '/>'); } else { $xml->addAttribute($name, $value); } } else { if ($name == 'nodeName') { $xml = $xml->addChild($value); } else { $xml->addAttribute($name, $value); } } } } if (isset($json->data)) { if (!is_null($xml)) { $xml = $xml->addCData($json->data); } } // Do the same for all child nodes if (isset($json->children)) { foreach ($json->children as $key => $val) { process($val, $xml); } } return $xml; }
<?php if (isset($_SERVER['REMOTE_ADDR'])) { echo "not for web\n"; exit(0); } function process($fn, $p) { echo $fn; echo $p; echo "\n"; $imgs = imagecreatefrompng($fn); for ($i = 0; $i < 6; $i++) { for ($j = 0; $j < 16; $j++) { $destimage = imagecreatetruecolor(24, 24); imagealphablending($destimage, false); $colorTransparent = imagecolorallocatealpha($destimage, 0, 0, 0, 127); imagefill($destimage, 0, 0, $colorTransparent); imagesavealpha($destimage, true); imagecopy($destimage, $imgs, 0, 0, $j * 24, $i * 24, 24, 24); $n = $p . chr($i * 16 + $j + 33); $n = bin2hex($n); imagepng($destimage, $n . ".png"); } } } process("aprs-symbols-24-0.png", "/"); process("aprs-symbols-24-1.png", "\\");
if (mb_stripos($text, '/unban', 0, 'UTF-8') !== FALSE && $from['id'] == administrator_id) { unban(mb_substr($text, 7, mb_strlen($text, 'UTF-8'), 'UTF-8')); } else { if (mb_stripos($text, '/feedback', 0, 'UTF-8') !== FALSE) { feedback($from['id'], mb_substr($text, 10, mb_strlen($text, 'UTF-8'), 'UTF-8')); } else { message($from['id'], $text); } } } break; } } } } process(); flushlog(); usleep(500000); } function feedback($userid, $text) { global $bot; $text = iconv('utf-8', 'windows-1251', $text); if (strlen($text) > 3) { file_put_contents('feedback', "\n" . date('d.m.Y H:i:s ' . $userid . ': ' . $text), FILE_APPEND); $bot->send($userid, 'Ваше сообщение записано. Спасибо!'); // "Your message wrote. Thanks!" } else { $bot->send($userid, 'Нет текста отзыва, используйте команду правильно - "/feedback текст" (без кавычек).'); // "No feedback text, use command right - /feedback text" }
<?php $input = '3113322113'; $output = ''; $rounds = 50; for ($i = 0; $i < $rounds; $i++) { if ($i == 0) { $output = process($input); } else { $output = process($output); } } echo strlen($output) . ' ' . $output . '<br>'; function process($input) { $out = ''; $arr = str_split($input); $length = count($arr); for ($i = 0; $i < $length; $i++) { if ($arr[$i] != $arr[$i + 1]) { $out .= '1' . $arr[$i]; } else { if ($arr[$i + 1] != $arr[$i + 2]) { $out .= '2' . $arr[$i]; $i = $i + 1; } else { if ($arr[$i + 2] != $arr[$i + 3]) { $out .= '3' . $arr[$i]; $i = $i + 2; } else { if ($arr[$i + 3] != $arr[$i + 4]) {
$user = "******"; $passwd = "07s49power"; $db = "smc"; $link = mysql_connect($url, $user, $passwd) or die("failed"); mysql_select_db($db, $link) or die("Not found such a database"); $sql = "SET CHARACTER SET UTF8"; mysql_query($sql, $link) or die("Can't set character-set to UTF8"); return $link; } $type = $_POST['check_type']; $id = $_POST['id']; $act = $_POST['success']; //main program $flag = connect(); if ($flag != false) { process($flag, $type, $id, $act); } ?> </div> <div id="keyboard"> <br> <span class=sub>Note</span> </div> <div id="drum" align=right> <br><br> 現在ページ作成中 ver.1.2  <br> </div>
if ($client < 0) { console("socket_accept() failed"); continue; } else { connect($client); } } else { $bytes = @socket_recv($socket, $stream, 2048, 0); if ($bytes == 0) { disconnect($socket); } else { $user = getuserbysocket($socket); if (!$user->handshake) { dohandshake($user, $stream); } else { process($user, $stream); } } } } } /******************** MESSAGING ********************/ function process($user, $msg) { $msg = unwrap($msg); // remove chr(0) and chr(255) say("< " . $msg); $parts = explode("|", $msg); // CHAT|NICK|MESSAGE $action = strtoupper($parts[0]); switch ($action) {