function iterate($graph, $nodes, $max, $cliques) { global $c1, $c2, $s, $k; // for every node in the graph as node1 foreach ($nodes as $key1 => $node1) { $c1++; $c2++; // for every node joined to node1 as node2 foreach ($node1->nodes as $key2 => $null) { $c1++; // if node1 and node2 are currently in a clique together, skip to next node2 if (isset($incl[$key2]) && isset($incl[$key2][$key1])) { continue; } $c2++; $node2 = $graph->nodes[$key2]; // clique <- [ node1, node2 ] $clique = array($key1 => $node1, $key2 => $node2); $c = 0; // c <- 0 // while c < |clique| // c = |clique| // clique = expand_clique( clique ) // ewhile while ($c != count($clique)) { $c1++; $c2++; $c = count($clique); $clique = expand($graph, $clique); } if (count($clique) < 2) { continue; } $cliques[] = $clique; $max = max($max, count($clique)); //if( count( $clique ) < 3 ) continue; foreach ($clique as $ke => $v) { $incl[$ke] = $clique; } } } return array($graph, $max, $cliques, $incl); }
} if ($show == 'mailsent' || $show == 'error') { $page['email'] = "*****@*****.**"; setup_logo(); expand("../styles", "{$preview}", "{$show}.tpl"); exit; } if ($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show == 'agentrochat') { setup_chatview_for_operator(array('threadid' => 0, 'userName' => getstring("chat.default.username"), 'remote' => "1.2.3.4", 'agentId' => 1, 'groupid' => 0, 'userid' => 'visitor1', 'locale' => $current_locale, 'ltoken' => $show == 'agentrochat' ? 124 : 123), array('operatorid' => $show == 'agentrochat' ? 2 : 1)); if ($show == 'redirect') { setup_redirect_links(0, $show == 'agentrochat' ? 124 : 123); } elseif ($show == 'redirected') { $page['message'] = getlocal2("chat.redirected.content", array("Administrator")); } $page['redirectLink'] = "{$webimroot}/operator/themes.php?preview={$preview}&show=redirect"; expand("../styles", "{$preview}", "{$show}.tpl"); exit; } $templateList = array(array('label' => getlocal("page.preview.userchat"), 'id' => 'chat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.chatsimple"), 'id' => 'chatsimple', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.nochat"), 'id' => 'nochat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.survey"), 'id' => 'survey', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.leavemessage"), 'id' => 'leavemessage', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.leavemessagesent"), 'id' => 'leavemessagesent', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.mail"), 'id' => 'mail', 'h' => 254, 'w' => 603), array('label' => getlocal("page.preview.mailsent"), 'id' => 'mailsent', 'h' => 254, 'w' => 603), array('label' => getlocal("page.preview.redirect"), 'id' => 'redirect', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.redirected"), 'id' => 'redirected', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.agentchat"), 'id' => 'agentchat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.agentrochat"), 'id' => 'agentrochat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.error"), 'id' => 'error', 'h' => 480, 'w' => 640)); $template = verifyparam("template", "/^\\w+\$/", "chat"); $page['formpreview'] = $preview; $page['formtemplate'] = $template; $page['canshowerrors'] = $template == 'leavemessage' || $template == 'mail' || $template == 'all'; $page['formshowerr'] = $showerrors; $page['availablePreviews'] = $stylelist; $page['availableTemplates'] = array("chat", "chatsimple", "nochat", "survey", "leavemessage", "leavemessagesent", "mail", "mailsent", "redirect", "redirected", "agentchat", "agentrochat", "error", "all"); $page['showlink'] = "{$webimroot}/operator/themes.php?preview={$preview}&" . ($showerrors ? "showerr=on&" : "") . "show="; $page['previewList'] = array(); foreach ($templateList as $tpl) { if ($tpl['id'] == $template || $template == 'all') { $page['previewList'][] = $tpl;
private function set_flag_capture_state($game_id, $objective_id, $state) { $game = $this->GetGame(array('GameId' => $game_id)); $obj = $this->GetObjective(array('ObjectiveId' => $objective_id)); if (count($game) == 0) { return false; } $state_source = array('Game' => $game, 'Objective' => $obj, 'State' => $state); $ret_state = false; /* Inputs Objective team_id = team_id|0 Game RunStatus = start|hold|finished Configuration Game GameTime: number (seconds) PointTarget: number ObjectiveTime: seconds|none Cumulative: cumulative|reset PointOnTarget: true|false States Game GameStatus = not-started|running|hold|finished TimeFrom AccumulatedTime Winner TeamPoints Objective TeamData CumulativeTime TimeStart */ /* ---------------------------------------------------- Basic CTF Game ---------------------------------------------------- */ $basic_ctf = array('PointOnTarget' => true); $start_resume_game = array_merge($basic_ctf, array('Objective' => 0, 'RunStatus' => 'start')); $ret_state |= $this->if_state($start_resume_game, $state_source, 'flag_capture_lookup', function ($src, $req) { expand($src); if (($winner = $this->flag_capture_find_point_frontrunner($Game)) > 0) { $Game['State']['GameStatus'] = 'running'; } $Game['State']['TimeFrom'] = time(); set_game_state($Game['GameId'], 0, $Game['State']); }); $hold_game = array_merge($basic_ctf, array('Objective' => 0, 'RunStatus' => 'hold', 'GameStatus' => 'running')); $ret_state |= $this->if_state($hold_game, $state_source, 'flag_capture_lookup', function ($src, $req) { expand($src); $Game['State']['AccumulatedTime'] += time() - $Game['State']['TimeFrom']; $Game['State']['GameStatus'] = 'hold'; set_game_state($Game['GameId'], 0, $Game['State']); }); $flag_captured = array_merge($basic_ctf, array('Objective' => 1, 'PointOnTarget' => true, 'GameStatus' => 'running')); $ret_state |= $this->if_state($flag_captured, $state_source, 'flag_capture_lookup', function ($src, $req) { expand($src); if (time() - $Game['State']['TimeFrom'] + $Game['State']['AccumulatedTime'] >= $Game['Configuration']['GameTime']) { $Game['State']['GameStatus'] = 'finished'; } if ($State['TeamId'] > 0) { $Game['State']['TeamPoints'][$State['TeamId']]++; } set_game_state($Game['GameId'], 0, $State); }); return true; }
$page['email'] = $email; if (!$email) { $errors[] = no_field("form.field.email"); } else { if (!is_valid_email($email)) { $errors[] = wrong_field("form.field.email"); } } if (count($errors) > 0) { $page['formemail'] = $email; $page['ct.chatThreadId'] = $thread['threadid']; $page['ct.token'] = $thread['ltoken']; $page['level'] = ""; setup_logo(); expand("styles", getchatstyle(), "mail.tpl"); exit; } $history = ""; $lastid = -1; $output = get_messages($threadid, "text", true, $lastid); foreach ($output as $msg) { $history .= $msg; } $subject = getstring("mail.user.history.subject"); $body = getstring2("mail.user.history.body", array($thread['userName'], $history)); $link = connect(); webim_mail($email, $webim_mailbox, $subject, $body, $link); mysql_close($link); setup_logo(); expand("styles", getchatstyle(), "mailsent.tpl"); exit;
$informat = "turtle"; $parser = ARC2::getRDFParser(); if ($intype === "direct") { $triples = $parser->parse($prefix, $input); } else { if ($intype === "url") { $triples = $parser->parse($input); } } $triples = $parser->getTriples(); if (count($triples) === 0) { die($help . "\n\nERROR: Could not create any triples, please check input: informat={$informat}, intype={$intype}\n"); } $logmessage .= "Retrieved/created " . count($triples) . " triples. "; $newtriples = array(); $newtriples = expand($parser); //write a log $logmessage .= "Created " . count($newtriples) . " new triple(s). Used " . round(memory_get_peak_usage() / 1000000, 2) . "mb max memory. Needed " . round(microtime(true) - $now, 2) . "ms"; $loguri = uniqid("urn:php:", true); $log = array(); $log[] = addTripleAllURIs($loguri, RLOG . 'level', RLOG . 'DEBUG'); $log[] = addTripleLiteral($loguri, RLOG . 'message', $logmessage); $log[] = addTripleLiteral($loguri, 'http://purl.org/dc/elements/1.1/creator', "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $log[] = addTripleAllURIs($loguri, RDF . 'type', RLOG . 'Entry'); $objDateTime = new DateTime('NOW'); $time = $objDateTime->format(DateTime::W3C); $log[] = array('type' => 'triple', 's' => $loguri, 'p' => NIF . "date", 'o' => $time, 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'literal', 'o_datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'); $triples = array_merge($triples, $newtriples, $log); if (@$_REQUEST['dummy'] === "true") { echo "@prefix nif: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#>.\n\t@prefix dbo: <http://dbpedia.org/ontology/>.\n\t@prefix owl: <http://www.w3.org/2002/07/owl#>.\n\t@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#>.\n\t@prefix prefix: <" . $prefix . "> .\n\t<" . $prefix . "char=0,39> \n\t\ta nif:RFC5147String , nif:Context ;\n\t\tnif:beginIndex \"0\";\n\t\tnif:endIndex \"39\";\n\t\tnif:isString \"\"\"My favorite actress is Natalie Portman.\"\"\" . \n\t\t\n\t<" . $prefix . "char=23,39> \n\t\ta nif:RFC5147String , nif:NamedEntity ;\n\t\tnif:beginIndex \"23\";\n\t\tnif:endIndex \"38\";\n\t\tnif:referenceContext <" . $prefix . "char=0,39> ;\n\t\titsrdf:taIdentRef <http://dbpedia.org/resource/Natalie_Portman> ;\n\t\titsrdf:taClassRef <http://nerd.eurecom.fr/ontology#Person> , dbo:Actor, dbo:Artist, dbo:Person, dbo:Agent, owl:Thing ;\n\t\tnif:taMsClassRef dbo:Actor .\n\t\t\n\t<http://dbpedia.org/resource/Natalie_Portman> a <http://nerd.eurecom.fr/ontology#Person> , dbo:Actor, dbo:Artist, dbo:Person, dbo:Agent, owl:Thing .\n\t<http://nerd.eurecom.fr/ontology#Person> <http://nerd.eurecom.fr/ontology#isCoreClass> \"1\" . "; die;
$errors[] = getlocal("chat.redirect.unknown_group"); } } else { $nextid = verifyparam("nextAgent", "/^\\d{1,10}\$/"); $nextOperator = operator_by_id($nextid); if ($nextOperator) { $page['message'] = getlocal2("chat.redirected.content", array(safe_htmlspecialchars(topage(get_operator_name($nextOperator))))); if ($thread['istate'] == $state_chatting) { $link = connect(); $threadupdate = array("istate" => intval($state_waiting), "nextagent" => intval($nextid), "agentId" => 0); if ($thread['groupid'] != 0) { if (FALSE === select_one_row("select groupid from {$mysqlprefix}chatgroupoperator where operatorid = " . intval($nextid) . " and groupid = " . intval($thread['groupid']), $link)) { $threadupdate['groupid'] = 0; } } commit_thread($threadid, $threadupdate, $link); post_message_($thread['threadid'], $kind_events, getstring2_("chat.status.operator.redirect", array(get_operator_name($operator)), $thread['locale'], true), $link); mysql_close($link); } else { $errors[] = getlocal("chat.redirect.cannot"); } } else { $errors[] = getlocal("chat.redirect.unknown_operator"); } } setup_logo(); if (count($errors) > 0) { expand("../styles", getchatstyle(), "error.tpl"); } else { expand("../styles", getchatstyle(), "redirected.tpl"); }
function pleac_Redefining_a_Function() { // In PHP once a function has been defined it remains defined. In other words, // it cannot be undefined / deleted, nor can that particular function name be // reused to reference another function body. Even the lambda-like functions // created via the 'create_function' built-in, cannot be undefined [they exist // until script termination, thus creating too many of these can actually // exhaust memory !]. However, since the latter can be assigned to variables, // the same variable name can be used to reference difference functions [and // when this is done the reference to the previous function is lost (unless // deliberately saved), though the function itself continues to exist]. // // If, however, all that is needed is a simple function aliasing facility, // then just assign the function name to a variable, and execute using the // variable name // Original function function expand() { echo "expand\n"; } // Prove that function exists echo (function_exists('expand') ? 'yes' : 'no') . "\n"; // Use a variable to alias it $grow = 'expand'; // Call function via original name, and variable, respectively expand(); $grow(); // Remove alias variable unset($grow); // ---------------------------- function fred() { echo "fred\n"; } $barney = 'fred'; $barney(); unset($barney); fred(); // ------------ $fred = create_function('', 'echo "fred\\n";'); $barney = $fred; $barney(); unset($barney); $fred(); // ---------------------------- function red($text) { return "<FONT COLOR='red'>{$text}</FONT>"; } echo red('careful here') . "\n"; // ------------ $colour = 'red'; ${$colour} = create_function('$text', 'global $colour; return "<FONT COLOR=\'$colour\'>$text</FONT>";'); echo ${$colour}('careful here') . "\n"; unset(${$colour}); // ---- $colours = split(' ', 'red blue green yellow orange purple violet'); foreach ($colours as $colour) { ${$colour} = create_function('$text', 'global $colour; return "<FONT COLOR=\'$colour\'>$text</FONT>";'); } foreach ($colours as $colour) { echo ${$colour}("Careful with this {$colour}, James") . "\n"; } foreach ($colours as $colour) { unset(${$colour}); } }
if (!is_capable($can_viewthreads, $operator)) { $errors = array("Cannot view threads"); start_html_output(); expand("../styles", getchatstyle(), "error.tpl"); exit; } } $token = $thread['ltoken']; header("Location: {$mibewroot}/operator/agent.php?thread=" . intval($threadid) . "&token=" . intval($token) . "&level=" . urlencode($remote_level)); exit; } $token = verifyparam("token", "/^\\d{1,10}\$/"); $thread = thread_by_id($threadid); if (!$thread || !isset($thread['ltoken']) || $token != $thread['ltoken']) { die("wrong thread"); } if ($thread['agentId'] != $operator['operatorid'] && !is_capable($can_viewthreads, $operator)) { $errors = array("Cannot view threads"); start_html_output(); expand("../styles", getchatstyle(), "error.tpl"); exit; } setup_chatview_for_operator($thread, $operator); start_html_output(); $pparam = verifyparam("act", "/^(redirect)\$/", "default"); if ($pparam == "redirect") { setup_redirect_links($threadid, $token); expand("../styles", getchatstyle(), "redirect.tpl"); } else { expand("../styles", getchatstyle(), "chat.tpl"); }
$level = get_remote_level($_SERVER['HTTP_USER_AGENT']); $chatstyle = verifyparam("style", "/^\\w+\$/", ""); header("Location: {$mibewroot}/client.php?thread={$threadid}&token={$token}&level={$level}" . ($chatstyle ? "&style={$chatstyle}" : "")); exit; } $token = verifyparam("token", "/^\\d{1,10}\$/"); $threadid = verifyparam("thread", "/^\\d{1,10}\$/"); $level = verifyparam("level", "/^(ajaxed|simple|old)\$/"); // We have to check that the thread is owned by the user. $is_own_thread = isset($_SESSION['own_threads']) && in_array($threadid, $_SESSION['own_threads']); $thread = thread_by_id($threadid); if (!$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] || !$is_own_thread) { die("wrong thread"); } setup_chatview_for_user($thread, $level); $pparam = verifyparam("act", "/^(mailthread)\$/", "default"); if ($pparam == "mailthread") { expand("styles", getchatstyle(), "mail.tpl"); } else { if ($level == "ajaxed") { expand("styles", getchatstyle(), "chat.tpl"); } else { if ($level == "simple") { expand("styles", getchatstyle(), "chatsimple.tpl"); } else { if ($level == "old") { expand("styles", getchatstyle(), "nochat.tpl"); } } } }
// example call: // php examples/macro-expand.php // "(defmacro when (condition a b c) (list 'if condition (list 'begin a b c)))" // "(when (> x 10) 1 2 3)" namespace Igorw\Ilias; require __DIR__ . '/../vendor/autoload.php'; if ($argc < 3) { echo "Usage: php examples/macro-expand.php MACROS CODE\n"; exit(1); } list($_, $macros, $code) = $argv; $program = new Program(new Lexer(), new Reader(), new FormTreeBuilder(), new Walker()); $env = Environment::standard(); $program->evaluate($env, $macros); $expandedForms = expand($env, $code); foreach ($expandedForms as $expanded) { echo encode($expanded->getAst()) . "\n"; } function buildForms($code) { $lexer = new Lexer(); $reader = new Reader(); $builder = new FormTreeBuilder(); $tokens = $lexer->tokenize($code); $ast = $reader->parse($tokens); return $builder->parseAst($ast); } function expand(Environment $env, $code) { $walker = new Walker();
if (empty($original) || empty($captcha) || $captcha != $original) { $errors[] = getlocal('errors.captcha'); } unset($_SESSION['mibew_captcha']); } if (count($errors) > 0) { setup_leavemessage($visitor_name, $email, $message, $groupid, $groupname, $info, $referrer, can_show_captcha()); setup_logo(); expand("styles", getchatstyle(), "leavemessage.tpl"); exit; } $message_locale = $settings['left_messages_locale']; if (!locale_exists($message_locale)) { $message_locale = $home_locale; } store_message($visitor_name, $email, $info, $message, $groupid, $referrer); $subject = getstring2_("leavemail.subject", array($visitor_name), $message_locale); $body = getstring2_("leavemail.body", array($visitor_name, $email, $message, $info ? "{$info}\n" : ""), $message_locale); if (isset($group) && !empty($group['vcemail'])) { $inbox_mail = $group['vcemail']; } else { $inbox_mail = $settings['email']; } if ($inbox_mail) { $link = connect(); webim_mail($inbox_mail, $email, $subject, $body, $link); mysql_close($link); } setup_logo(); expand("styles", getchatstyle(), "leavemessagesent.tpl");
<?php require_once '/home/octaaron/aaron/controleurs/objetsphp/rss/controleur_rssfeed.php'; /** * Created by PhpStorm. * User: Thomas * Date: 21/12/2015 * Time: 12:35 */ header('Access-Control-Allow-Origin: *'); if (isset($_POST['action']) && isset($_POST['url'])) { switch ($_POST['action']) { case 'expand': expand($_POST['url']); break; } } function expand($url) { try { $feed = new RssFeed($url); echo $feed->displayPosts(); } catch (Exception $e) { echo $e->getMessage(); } exit; }