$tokens->extract(1, 3); test($tokens->key(), 1, 'extract multiple over position'); // insert() $tokens = clone $tokenStream; $tokens->seek(2); $tokens->insert(1, array('(', ')')); test($tokens->key(), 4, 'insert before position'); $tokens->insert(1, array('(', ')', array('(', ')'))); test($tokens->key(), 8, 'insert recursive before position'); }); group('interface ArrayAccess', function () use($tokenStream) { $tokenStream = clone $tokenStream; test($tokenStream[0]->content, "<?php\n", 'get offset'); $tokenStream[0] = new Token(T_OPEN_TAG, "<?\n", 1); test($tokenStream[0]->content, "<?\n", 'set offset'); $tokenStream[] = new Token(T_CLOSE_TAG, '?>', 2); test($tokenStream[5]->content, '?>', 'append'); test(isset($tokenStream[6]), false, 'isset'); unset($tokenStream[0]); // pass if no error test(isset($tokenStream[0]), true, 'unset moves tokens down'); testException(function () use($tokenStream) { $tokenStream[5]; }, 'OutOfBoundsException', 'getting non existing offset'); testException(function () use($tokenStream) { unset($tokenStream[5]); }, 'OutOfBoundsException', 'unsetting non existing offset'); testException(function () use($tokenStream) { $tokenStream[] = 0; }, 'InvalidArgumentException', 'setting to non-token'); });
<?php require './test.php'; require '../src/TokenStream.php'; $tokenStream = new TokenStream("<?php\ndie();"); group('get', function () use($tokenStream) { test(streamEqual($tokenStream->get(1, 2), array(new Token(T_EXIT, 'die'), new Token(T_OPEN_ROUND, '('))), true, 'get(int, int)'); }); group('extract', function () use($tokenStream) { $tokenStream = clone $tokenStream; test(streamEqual($tokenStream->extract(1, 2), array(new Token(T_EXIT, 'die'), new Token(T_OPEN_ROUND, '('))), true, 'return value of extract(int, int)'); test(streamEqual($tokenStream->get(0, count($tokenStream) - 1), array(new Token(T_OPEN_TAG, "<?php\n"), new Token(T_CLOSE_ROUND, ')'), new Token(T_SEMICOLON, ';'))), true, 'stream change of extract(int, int)'); test(tokenEqual($tokenStream->extract(2), new Token(T_SEMICOLON, ';')), true, 'return value of extract(int)'); test(streamEqual($tokenStream->get(0, count($tokenStream) - 1), array(new Token(T_OPEN_TAG, "<?php\n"), new Token(T_CLOSE_ROUND, ')'))), true, 'stream change of extract(int)'); }); group('append', function () use($tokenStream) { $tokenStream = clone $tokenStream; $tokenStream->append(array(new Token(T_WHITESPACE, "\n"), '{', '}', array(';'))); test((string) $tokenStream, "<?php\ndie();\n{};", 'append token array'); $tokenStream->append(';'); test((string) $tokenStream, "<?php\ndie();\n{};;", 'append single token'); }); group('insert', function () use($tokenStream) { $tokenStream = clone $tokenStream; $tokenStream->insert(1, array('{', '}', array(';', new Token(T_WHITESPACE, "\n")))); test((string) $tokenStream, "<?php\n{};\ndie();", 'insert token array'); $tokenStream->insert(4, ';'); test((string) $tokenStream, "<?php\n{};;\ndie();", 'insert single token'); });
function addScore($uid, $semester, $type_name, $class_chinese_name, $score) { //$type = getClassTypeByTypeName($type_name); $type = $type_name; $table = getTableName($semester, $type); $class_type = getClassEnglishName($class_chinese_name); //需先判断是否存在该uid记录 $sql = "SELECT id FROM {$table} WHERE uid = {$uid}"; $res = mysql_query($sql); if (@mysql_fetch_assoc($res)["id"]) { $sql = "UPDATE {$table} SET {$class_type} = {$score} WHERE uid = {$uid}"; } else { $sql = "INSERT INTO {$table}(uid,{$class_type}) VALUES({$uid},{$score})"; } if (mysql_query($sql)) { addMessage($uid, 1, 1); addAverage($uid, $semester, $type_name); group($uid, $semester); return 1; } else { return 0; } }
function mygroupDispatch($op) { if (isset($_POST['undo'])) { $op = 'group'; } if (isset($_POST['save'])) { $op = 'savesel'; } switch ($op) { case "group": group(); break; case "savesel": savesel(); break; } }
$period = "In der letzten Woche gehört von"; echo group($db_name, $period); break; case 5: include "user_love_track.php"; break; case 6: include "user_topartist.php"; break; case 7: include "user_toptrack.php"; break; case 8: $db_name = "last_fm_charts_all"; $period = "Gehört von"; echo group($db_name, $period); break; default: break; } ?> </section><br/><br/> </div> <?php echo footer($method_in, $page, $totalPages, $user_in, $limit_in, $perPage); ?> </div> <script type="text/javascript" src="https://msn.ldkf.de/js/jquery-1.11.2.min.js"></script> <script type="text/javascript" src="https://msn.ldkf.de/js/bootstrap.min.js"></script> <script type="text/javascript"> $(document).ready(function () {
test($tokenStream->findEOS(6), 12, 'find eos tag'); test($tokenStream->find(0, T_OPEN_TAG), false, 'find from already matchind token'); test($tokenStream->find($max, T_EXIT, true), 2, 'find token backwards'); test($tokenStream->find(0, T_OPEN_TAG, true), false, 'find from first index backwards'); test($tokenStream->findEOS($max, true), 6, 'find eos semicolon'); // 0 123 4567890 $hacker = new TokenStream('<?php A(function(){;});'); test($hacker->findEOS(2), 10, 'find EOS skipping lambda'); test($hacker->findEOS(9, true), 0, 'find EOS skipping lambda backwards'); // 0 123 $hacker = new TokenStream('<?php {} '); test($hacker->findEOS(3, true), 2, 'find closing bracket as EOS backwards'); }); group('skip', function () use($tokenStream, $max) { test($tokenStream->skip(0, T_WHITESPACE), 2, 'skip token'); test($tokenStream->skip(0, array(T_WHITESPACE, T_EXIT)), 3, 'skip tokens'); test($tokenStream->skip($max, array(T_WHITESPACE, T_CONSTANT_ENCAPSED_STRING), true), 8, 'skip tokens backwards'); test($tokenStream->skipWhitespace(0), 2, 'skip whitespace'); }); // 0 12 34 5678901 234 56 789 $tokenStream = new TokenStream('<?php (hi,hi,(),((hi),hi)) (()'); group('complementaryBracket', function () use($tokenStream) { test($tokenStream->complementaryBracket(1), 16, 'find forward'); test($tokenStream->complementaryBracket(15), 9, 'find backwards'); testException(function () use($tokenStream) { $tokenStream->complementaryBracket(17); }, 'TokenException', 'brackets not matching'); testException(function () use($tokenStream) { $tokenStream->complementaryBracket(2); }, 'TokenException', 'not a bracket'); });
public function testGroupOfGroupsAndCombinedFilters() { $result = group(filter('ID')->equal->value('value')->and->filter('FOO')->equal->value('bar'))->or->group(filter('ID')->equal->value('val')->and->filter('FOO')->equal->value('baz'))->or->filter('YOP')->less->value('bla'); $this->assertEquals('(ID=value and FOO=bar) or (ID=val and FOO=baz) or YOP<bla', $result->to_string()); }
//Enroll student in course enroll($_POST['id']); $msg->addFeedback('MEMBERS_ENROLLED'); header('Location: index.php?current_tab=0' . SEP . 'course_id=' . $course_id); exit; } else { if (isset($_POST['submit_yes']) && $_POST['func'] == 'alumni') { //Mark student as course alumnus alumni($_POST['id']); $msg->addFeedback('MEMBERS_ALUMNI'); header('Location: index.php?current_tab=2' . SEP . 'course_id=' . $course_id); exit; } else { if (isset($_POST['submit_yes']) && $_POST['func'] == 'group') { //Mark student as a member of the group group($_POST['id'], $_POST['gid']); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: index.php?current_tab=' . $_POST['current_tab'] . SEP . 'course_id=' . $course_id); exit; } else { if (isset($_POST['submit_yes']) && $_POST['func'] == 'group_remove') { // Remove student as a member of the group group_remove($_POST['id'], $_POST['gid']); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: index.php?current_tab=' . $_POST['current_tab'] . SEP . 'course_id=' . $course_id); exit; } } } } }
<?php require './test.php'; require '../src/TokenStream.php'; group('empty stream', function () { $tokenStream = new TokenStream(); test(count($tokenStream), 0, 'argumentless'); $tokenStream = new TokenStream(''); test(count($tokenStream), 0, 'empty string'); }); group('source', function () { test(streamEqual(new TokenStream("<?php\ndie();"), array(new Token(T_OPEN_TAG, "<?php\n"), new Token(T_EXIT, 'die'), new Token(T_OPEN_ROUND, '('), new Token(T_CLOSE_ROUND, ')'), new Token(T_SEMICOLON, ';'))), true, 'normal source'); test(streamEqual(new TokenStream("<?php namespace\\A"), array(new Token(T_OPEN_TAG, "<?php "), new Token(T_NAMESPACE, 'namespace'), new Token(T_NS_SEPARATOR, '\\'), new Token(T_STRING, 'A'))), true, 'source with 5.3 tokens'); });
function user() { if ($_GET["ou"] == null) { org(); exit; } if ($_GET["group"] == null) { group(); exit; } if ($_GET["domain"] == null) { domain(); exit; } $html = "<H5>{$_GET["ou"]}: {$_GET["group"]}: {$_GET["domain"]}: {user}</H5>\n\t<table style='width:100%'>\n\t<tr>\n\t<td width=1% valign='top'><img src='img/chiffre5.png'></td>\n\t<td>\n\t<p class=caption>{user_text}</p>\n\t<input type='hidden' id='ou'value='{$_GET["ou"]}'>\n\t<input type='hidden' id='group' value='{$_GET["group"]}'>\n\t<input type='hidden' id='domain' value='{$_GET["domain"]}'>\n\t<input type='hidden' id='domain_ip' value='{$_GET["domain_ip"]}'>\n\t<table style=width:100%>\n\t<tr>\n\t<td align='right'>{uid}</td>\n\t<td>\n\t" . Field_text('uid', $_GET["uid"], 'width:150px') . "\n\t</td>\n\t</tr>\n\t<tr>\n\t<td align='right'>{password}</td>\n\t<td>\n\t" . Field_text('password', $_GET["password"], 'width:150px') . "\n\t</td>\n\t</tr>\t\n\t</table>\n\t<br>\n\t<hr>\n\t<table style='width:100%'>\n\t<tr>\n\t<td><input type='button' OnClick=\"javascript:firstwizard_4();\" value='« {back}'></td>\n\t<td align='right'><input type='button' OnClick=\"javascript:Build();\" value='{build} »'></td>\n\t\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }
$res3 = $row['res3']; $res4 = $row['res4']; $z++; $groupid = $row['groupid']; $attack_time = $row['traveltime'] + $op_battle_countdown_time; if ($attack_time < time()) { header("LOCATION: battle.php?action=abort&gid={$groupid}"); exit; } $requesttime = $row['traveltime'] - time(); $message_1 = ""; $result_island = $db->query("SELECT * FROM cc" . $n . "_countries WHERE x = '{$row['endx']}' AND y = {$row['endy']}"); $row_island = $db->fetch_array($result_island); $island_name = $row_island['name'] . " (" . $row_island['x'] . ":" . $row_island['y'] . ")"; $to_islandid = $row_island['islandid']; $group_name = group($groupid); $groupid = $row['groupid']; $time = time(); $result_inhalt = $db->query("SELECT * FROM cc" . $n . "_groups_inhalt WHERE group_id='{$row['groupid']}'"); $inhalt = ""; while ($row_inhalt = $db->fetch_array($result_inhalt)) { $result_name = $db->query("SELECT * FROM cc" . $n . "_soldiers WHERE tabless='{$row_inhalt['type']}' AND race = '{$userdata['rassenid']}'"); $row_name = $db->fetch_array($result_name); $inhalt .= trim($row_name['name']) . " -> " . $row_inhalt['anzahl'] . "<br>"; } if ($requesttime > 0) { $z++; $message = make_timebanner($row['starttime'], $row['traveltime'], $z, "battle.php"); } else { $z++; $attack_request_time = $attack_time - time();
<?php require './test.php'; require '../src/TokenStream.php'; $tokenStream = new TokenStream("<?php\ndie();"); group('__toString', function () use($tokenStream) { test((string) $tokenStream, "<?php\ndie();", '(string) $tokenStream'); }); echo '<p>The debugDump method is hard to test. But try this: If you like the following output, everything\'s okay. If not, test failed ;)</p>'; $tokenStream = new TokenStream(file_get_contents(__FILE__)); $tokenStream->debugDump(true, true, false);
$token->undefined; }, 'InvalidArgumentException', 'getting undefined property'); test($token->type, T_OPEN_ROUND, 'getting property: type'); test($token->content, '(', 'getting property: content'); test($token->line, 0, 'getting property: line'); test($token->id, 1, 'getting property: id'); test($token->name, "'('", 'getting property: name (char token)'); test($funcToken->name, 'T_FUNCTION', 'getting property: name ("real" token)'); test((string) $token, '(', '(string) $token'); }); group('magic setters', function () use($token, $funcToken) { testException(function () use($token) { $token->undefined = 'a'; }, 'InvalidArgumentException', 'setting undefined property'); testException(function () use($token) { $token->id = 1; }, 'InvalidArgumentException', 'setting id not allowed'); testException(function () use($token) { $token->name = 1; }, 'InvalidArgumentException', 'setting name not allowed'); $token = clone $token; $token->type = T_FUNCTION; $token->content = 'function'; $token->line = 1; test(tokenEqual($token, $funcToken), true, 'setting properties'); }); group('Token->is()', function () use($token) { test($token->is(T_OPEN_ROUND), true, 'is(token)'); test($token->is(array(T_CLOSE_ROUND, T_OPEN_ROUND)), true, 'is(array(token, token))'); test($token->is(T_CLOSE_ROUND, T_OPEN_ROUND), true, 'is(token, token)'); });
<?php group('y:z', function () { task('a', function () { echo "y:z:a\n"; }); }); task('a:b', function () { echo "a:b\n"; }); group('b', function () { task('a', function () { echo "b:a\n"; }); }); task('default', 'a:b', 'b:a', 'y:z:a');
/> </div> <div class="group-addons"> <?php foreach ($addons as $addon) { if ($addon) { addon($addon); } } ?> </div> </div> <?php } foreach ($allgroups as $group) { group($group, $addons[$group['id']]); } ?> </div> <div id="groups-tail"> <p>直接從頁面安裝附加元件的說明會出現在這裡。</p> </div> <div id="window_addons" class="window" title="新增附加元件"> <form action="#" id="addon_query_form"> <p>搜尋: <?php print form_input(array('id' => 'addon_query', 'value' => '')); ?> <button type="submit">尋找附加元件</button></p> </form> <p id="addon_query_desc"> </p> <p id="addon_query_notfound">沒有找到任何附加元件,可能是因為您要找的附加元件從未被推薦過。您可以在搜尋攔貼上該附加元件在 <a href="https://addons.mozilla.org/" class="newwindow">Mozilla 附加元件</a>網站的網址直接推薦。</p>
} echo '</td><td width=150 align=right> <a href="' . $home_url . 'edit_object/' . $group[id] . '">Изменить</td></tr>'; } while ($group = mysql_fetch_array($sql_groups)); echo '</table>'; } else { echo '<div style="text-align:center;">Пусто</div>'; } } if ($this_page == 'students') { $sql_groups = mysql_query("SELECT * FROM `students` ORDER BY `group_id`, `name`"); if (mysql_num_rows($sql_groups) > 0) { $group = mysql_fetch_array($sql_groups); $group_id = 0; do { if ($group_id !== $group[group_id]) { echo '</table><div style="text-align:Center;font-size:2em;"><b>' . group($group[group_id]) . '</b></div><table width="100%">'; $group_id = $group[group_id]; } echo '<tr><td width=250><b>' . $group[surname] . ' ' . $group[name] . '</b></td><td>' . $group[idnp] . '</td><td width=150 align=right> <a href="' . $home_url . 'edit_student/' . $group[id] . '">Изменить</td></tr>'; } while ($group = mysql_fetch_array($sql_groups)); echo '</table>'; } else { echo '<div style="text-align:center;">Пусто</div>'; } } if ($this_page == 'edit_group' && is_numeric($arr[1])) { $sql_group = mysql_query("SELECT * FROM `group` WHERE `id`='{$arr['1']}'"); if (mysql_num_rows($sql_group) > 0) { $group = mysql_fetch_array($sql_group); ?> <input type="text" name="name" id="name" placeholder="Навзание группы" class="form-control" value="<?php
<?php function p($t) { echo $t . "\n"; } group('bleem', function () { desc('bleem:baz'); task('baz', ':bleem', function () { p(1); }); after('baz', function () { p(2); }); }); desc('bleem'); task('bleem', function () { p(0); }); after('bleem:baz', function () { p(3); }); desc('foo'); task('foo', function () { p(5); }); desc('bar'); task('bar', function () { p(8); }); task('foo', function () {
function RUN_Topic() { global $logged, $permissions; if (is_numeric($_GET['id']) and !empty($_GET['id'])) { $id = intval(htmlspecialchars($_GET['id'])); } else { pageerror("Topic Error", "", "Sorry, but there wasn't a topic id present."); } if (!getFP(topic_parent_($id), 1)) { pageerror("Permission Error", "", "Sorry, but you don't have permissions viewing this topic."); } //do some post stuff //total replies pagination limit $ppt = mysql_query("SELECT `postpertopic` FROM `boardstatus` LIMIT 1"); $p_p_t = mysql_fetch_array($ppt); $total_limit = $p_p_t['postpertopic']; topic_pagination($id, $total_limit); $main = mysql_query("SELECT * FROM `topics` WHERE `id` = '" . $id . "' "); $tmain = mysql_fetch_array($main); $umain = mysql_query("SELECT * FROM `users` WHERE `username` = '" . $tmain['username'] . "'"); $fuser = mysql_fetch_array($umain); $isSticked = $tmain['sticky'] == 1 ? "<a href='mode.php?type=sticktopic&tid=" . $id . "'>Sticky</a>" : "<a href='mode.php?type=unsticktopic&tid=" . $id . "'>Un-Sticky</a>"; $isLocked = $tmain['closed'] == 1 ? "<a href='mode.php?type=closetopic&tid=" . $id . "'>Lock</a>" : "<a href='mode.php?type=opentopic&tid=" . $id . "'>Un-Lock</a>"; //check if user has permissions if ($permissions['admin'] == 't' || $permissions['e_topic'] == 't') { $modet = "<a href='mode.php?type=edit&post=topic&id=" . $id . "'>Edit</a> | <a href='mode.php?type=move&post=topic&id=" . $id . "'>Move Topic</a> | " . $isSticked . " | " . $isLocked; } elseif ($logged['username'] == $tmain['username'] && $permissions['e_topic'] == 't') { $modet = "<a href='mode.php?type=edit&post=topic&id=" . $id . "'>Edit</a>"; } else { $modet = ""; } echo "<br />" . run_buttons($id); $Temp = new Template(); $Temp->dir = $logged['dskin']; $Temp->file = "topic_title.tpl"; $Temp->tp(); $Temp->tr(array('TITLE' => $tmain['title'])); echo $Temp->html; //if($_GET['p'] == 1 || !isset($_GET['p']) ) // { echo ' <tr> <td colspan="2" class="small_title"><span style="float:left;"><b>Posted On:</b> ' . timezone_stamp($tmain['timestamp'], $logged['timezone']) . '</span><span style="float:right" class="small_title_link">' . $modet . '</span></td> </tr> '; //} if (!isset($_GET['p']) || empty($_GET['p']) || $_GET['p'] == 0) { $page = 1; } else { if (!is_numeric($_GET['p'])) { pageerror("Page Error", "", "Didn't specify a correct page id."); } else { $page = intval(mysql_real_escape_string($_GET['p'])); } } $limit_start = $page * $total_limit - $total_limit; //get replies $replies = mysql_query("SELECT * FROM `replies` WHERE `tid` = '" . $id . "' ORDER BY `id` LIMIT {$limit_start},{$total_limit}") or die(mysql_error(__FILE__, __LINE__)); $has_replys = mysql_num_rows($replies); if ($has_replys != 0) { //check to see if there are any replies :D while ($replys = mysql_fetch_array($replies)) { //check if user has permissions if ($permissions['admin'] == 't' || $permissions['d_post'] == 't') { $modep = "<a href='mode.php?type=edit&post=reply&id=" . $replys['id'] . "&tid=" . $id . "'>Edit</a> | <a href='mode.php?type=delete&post=reply&id=" . $replys['id'] . "&tid=" . $id . "'>Delete</a>"; } elseif ($logged['username'] == $replys['username']) { $modep = "<a href='mode.php?type=edit&post=reply&id=" . $replys['id'] . "&tid=" . $id . "'>Edit</a>"; } else { $modep = ""; } $usez = mysql_query("SELECT * FROM `users` WHERE `username` = '" . $replys['username'] . "'"); $useri = mysql_fetch_array($usez); //show replies $Temp = new Template(); $Temp->dir = $logged['dskin']; $Temp->file = "topic_post.tpl"; $Temp->tp(); $Temp->tr(array('OPTIONS' => $modep, 'POSTER' => $replys['username'], 'AVY' => !empty($useri['avatar']) ? '<img width="100" height="100" src="' . $useri['avatar'] . '" alt="" /><br />' : '', 'DATE' => timezone_stamp($replys['date'], $logged['timezone']), 'GROUP' => group($useri['level']), 'UID' => $useri['id'], 'UPOST' => $useri['post'], 'POST' => nl2br(bbcode_format($replys['post'])) . "<br />__________________<br />" . ($useri['signature'] == '' ? ' ' : nl2br(bbcode_format($useri['signature']))))); echo $Temp->html; } } else { echo "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width='100%' class='rows' align='center'><em>There isn't any posts in this topic</em></td>\n\t\t\t\t\t</tr>\n\t\t\t\t"; } echo ' </table> ' . run_buttons($id) . '<br />'; topic_pagination($id, $total_limit); add_views($id); }