function do_method($a, $v = null) { $p = $this->target ? $this->target : $this; $args = optimize_args(func_get_args()); /*get callback*/ foreach ($args as $z) { if (ispack($z) && type($z) == 'object') { $cb = $z; } } $methods = $this->methods($p); if (isStr($a)) { if (isIn($a, $methods)) { $p->{$a}($v); } else { if (isset($cb)) { $cb($p, array($a, $v)); } else { $p->attr($a, $v); } } } else { while (list($i, $v_) = _each($args, $k)) { if (isStr($i)) { $this->do_method($i, $v_); } if (isDrw(OBJ($v_))) { foreach ($v_ as $l => $v1) { $this->do_method($l, $v1); } } } } return $this; }
/** * Returns a deep copy of the given value. `Callable`s are not copied but returned by reference. * ```php * $data = (object) [ * 'content' => (object) ['name' => 'foo'], * 'other' => 'value' * ]; * * $clonedData = clone_($data); * $clonedData->content->name = 'bar'; * * $clonedData; // stdClass({content: {name: 'bar'}, other: 'value'}) * $data; // stdClass({content: {name: 'foo'}, other: 'value'}) * ``` * * @signature a -> a * @param mixed $value * @return mixed */ function clone_() { $clone = function ($value) { switch (type($value)) { case 'Null': case 'Boolean': case 'String': case 'Function': case 'Resource': case 'Number': return $value; case 'ArrayObject': case 'Array': case 'List': return map(clone_(), $value); case 'Error': case 'Stream': case 'Object': $result = clone $value; foreach (keys($value) as $key) { $result->{$key} = clone_($result->{$key}); } return $result; } return $value; }; return apply(curry($clone), func_get_args()); }
/** * Creates a new Stream with the provided $data. * ```php * Stream::of(1); // Stream(1) * Stream::of(1, 'Hello'); // Stream([1, 'Hello']) * Stream::of([1, 2, 3]); // Stream([1, 2, 3]) * ``` * * @signature a -> Stream(a) * @param mixed $data * @return Stream */ public static function of($data) { $data = func_get_args(); if (count($data) == 1) { $data = $data[0]; } return new Stream($data, [], type($data)); }
function assign_link(&$o, $url = '', $targ = '_parent') { if (type(OBJ($o, false)) == 'a') { _($o)->attr(array('href' => $url, 'target' => $targ)); } else { $l = c_link($o, $url, $targ); _($o)->parent()->replaceChild($o, $l); $o = $l; } }
function valid_datetime_object($t) { //only date if (type($t) == '_Date') { $y = $t->get_date(); } elseif (type($t) == 'DateTime') { $y = $t; } if (isStr($t) && isDate($t)) { $s = explode('-', $t); $y = new DateTime(); $y->setDate($s[0], $s[1], $s[2]); } if (isset($y)) { return $y; } else { return false; } }
function type($fid = 0, $n = 0, $fstr) { $fstr .= ">" . $fid; $n++; //获取fid对应的分类 $ob = M("producttype"); $arr = $ob->where("fid={$fid}")->select(); /* echo"<pre>"; echo $n; var_dump($arr); echo"</pre>"; */ for ($i = 1; $i < $n; $i++) { $kStr .= " "; } foreach ($arr as $v) { $id = $v['id']; $newFstr = substr($fstr, 2); if ($n == 1) { $str .= "<option value='{$newFstr}>{$id}>'>{$v['name']}</option>"; } else { $str .= "<option value='{$newFstr}>{$id}>'>{$kStr}{$v['name']}</option>"; } //查找$id是否有子分类,找到它的子分类对应的数组 $sarr = $ob->where("fid={$id}")->select(); /*echo"<pre>"; var_dump($arr); echo"</pre>";*/ if (!empty($sarr) && is_array($sarr)) { $str1 = type($id, $n, $fstr); $str = $str . $str1; } } return $str; }
require_once '../models/data/ItemInfo.php'; $des_name = time(); $im = new ItemInfo(); try { $fp = fopen('./12345', 'r'); $data = array(); while (!feof($fp)) { $line = fgets($fp); $line = preg_replace('/\\t{1,}/', ' ', $line); //去掉多个tab制表位 $line = preg_replace('/\\s{2,}/', ' ', $line); //去掉多个空格 $l = explode(" ", $line); $l[1] = gender($l[1]); $l[2] = type($l[2]); if ($l[0] == null) { continue; } $data[] = $l; } $cons = '`id`,`itemGender`,`type`,`itemName`,`itemDate`'; $ln = null; foreach ($data as $k => $v) { $time = time(); array_walk($v, 'trim_arr'); $ln .= '(\''; $ln .= join($v, '\',\''); $ln .= '\',\'' . $time . '\'),'; } $ln = trim($ln, ",") . ';';
function string() { type('is_string', func_get_args()); }
$sql = "SELECT * FROM users WHERE username = '******' AND password = '******'"; $result = @$database->query($sql) or die("No."); // Huge error // Cookies don't match and no session, so tell them to logout! if ($database->num($result) < 1) { session_destroy(); unset($username); unset($password); include $config['template_path'] . "header.php"; print_out(lang('error_with_cookies'), lang_parse('error_cookie_body', array($config['url_path'] . '/logout.php')), false); } else { if ($database->num($result) > 0) { // Get the users data $user_data = $database->fetch($result); // What is this user classified as? $type = type($user_data['username']); // Tell us what they are switch ($type) { case 1: $_SESSION['admin'] = true; break; case 2: $_SESSION['moderator'] = true; break; case 3: $_SESSION['banned'] = true; break; default: break; } // Update their session
/** * Signs user in based on username or email * @global array * @global resource * @param boolean|string $username username or false * @param boolean|string $email user email or false * @param string $password user password * @return int|boolean */ function login($username, $email = false, $password) { global $config, $database; // Error codes // 904 - empty email // 905 - invalid email // 906 - invalid username // 907 - invalid chars in username // 908 - banned [.] // email is true? if ($email) { // is just true or null? if (empty($email)) { return 904; } // are we using email? if (is_email($email)) { // Encrypt the password $password = md5($password); // login before load_hook('login_before'); // Query $query = "SELECT * FROM `users` WHERE `email` = '{$email}' AND `password` = '{$password}' LIMIT 1"; // Return Data $return = $database->query($query); // Exists? if ($database->num($return) > 0) { // Finally return Results $user_data = $database->fetch($return); // Are they banned? if ($user_data['banned']) { return 908; } // What is this user classified as? $type = type($user_data['username']); // Tell us what they are switch ($type) { case 1: $_SESSION['admin'] = true; break; case 2: $_SESSION['moderator'] = true; break; case 3: $_SESSION['banned'] = true; break; default: break; } // logged in load_hook('login_after'); // Update their session $_SESSION['logged_in'] = true; $_SESSION['user_id'] = $user_data['id']; $_SESSION['user_name'] = $user_data['username']; // Last seen update_user($user_data['id'], false, 'last_seen', time()); // Set Cookie if ($config['allow_cookies']) { setcookie('login', "{$username}|{$password}", time() + 86400 * 365 * 2, $config['cookie_domain'], '.ninkobb.com'); } } else { return false; } } else { // guess it wasn't a real one. return 905; } } else { // Was it empty? if (empty($username)) { return 906; } // Checking for invalid characters if (!alpha($username, 'alpha-underscore')) { return 907; } // Encrypting password $password = md5($password); // login before load_hook('login_before'); // Query $query = "SELECT * FROM `users` WHERE `username` = '{$username}' AND `password` = '{$password}' LIMIT 1"; // Return Data $return = $database->query($query); // Exists? if ($database->num($return) > 0) { // Finally return Results $user_data = $database->fetch($return); // Are they banned? if ($user_data['banned']) { return 908; } // What is this user classified as? $type = type($user_data['username']); // Tell us what they are switch ($type) { case 1: $_SESSION['admin'] = true; break; case 2: $_SESSION['moderator'] = true; break; case 3: $_SESSION['banned'] = true; break; default: break; } // login before load_hook('login_after'); // Update their session $_SESSION['logged_in'] = true; $_SESSION['user_id'] = $user_data['id']; $_SESSION['user_name'] = $user_data['username']; // Last seen update update_user($user_data['id'], false, 'last_seen', time()); // Set Cookie if ($config['allow_cookies']) { setcookie('login', "{$username}|{$password}", time() + 86400 * 365 * 2, $config['cookie_domain'], '.ninkobb.com'); } return true; } else { return false; } } }
$n = isset($_GET['limit']) ? $_GET['limit'] : null; $search = new Search(); $like = new UserLikeModel(); $re = $search->search($_GET['key'], $page, $uid, $n); while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) { $line['islike'] = $like->checkUserLike($uid, $line['id']); $line['likesum'] = $like->itemLikeSum($line['id']); $data[] = $line; } echo $style->show(200, $data); } elseif ($_GET['key'] && $_GET['type']) { $data = array(); $uid = isset($_GET['uid']) ? $_GET['uid'] : null; $page = isset($_GET['page']) ? $_GET['page'] : 1; if (isset($_GET['type'])) { $type = type($_GET['type']); } $search = new Search(); $like = new UserLikeModel(); $re = $search->search_admin($_GET['key'], $type, $page); while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) { $line['islike'] = $like->checkUserLike($uid, $line['id']); $line['likesum'] = $like->itemLikeSum($line['id']); $data[] = $line; } echo $style->show(200, $data); } else { echo $style->show(400); } function type($type) {
function replaceChild($new, $old = null) { if (!$this->more()) { if (isDrw($new) || type($new) == 'DRW') { while (list($i, $v) = _each($new, $k)) { $this->replaceChild($i, $v); } } if (isEle($new) && isEle($old)) { $this->O->replaceChild($new, $old); } } else { foreach ($this->O as $v) { _($v)->replaceChild($new, $old); } } return $this; }
/** * Returns `true` if the two elements have the same type and are deeply equivalent. * ```php * $a = (object) ['a' => 1, 'b' => (object) ['c' => 'Hello'], 'd' => false]; * $b = (object) ['a' => 1, 'b' => (object) ['c' => 'Hi'], 'd' => false]; * $c = (object) ['a' => 1, 'b' => ['c' => 'Hello'], 'd' => false]; * equals(5, '5'); // false (should have the same type) * equals([1, 2, 3], [1, 2, 3]); // true * equals([1, 3, 2], [1, 2, 3]); // false (should have the same order) * equals($a, $b); // false * equals($a, $c); // false * $b->b->c = 'Hello'; * equals($a, $b); // true * ``` * * @signature * -> * -> Boolean * @param mixed $a * @param mixed $b * @return bool */ function equals() { $equals = function ($a, $b) { $type = type($a); if ($type != type($b)) { return false; } switch ($type) { case 'Null': case 'Boolean': case 'String': case 'Number': case 'Unknown': case 'Function': case 'Resource': case 'Error': case 'Stream': return $a == $b; case 'List': $length = length($a); return length($b) != $length ? false : 0 == $length ? true : equals(head($a), head($b)) && equals(tail($a), tail($b)); case 'Array': case 'ArrayObject': case 'Object': return equals(keys($a), keys($b)) && equals(values($a), values($b)); } }; return apply(curry($equals), func_get_args()); }
{ return "type {$argNum}"; } /** * element type of argument #$argNum * @param mixed $argNum * @return mixed */ function elementType($argNum) { return "elementType {$argNum}"; } override(\array_shift(0), elementType(0)); override(\array_reverse(0), elementType(0)); override(\array_pop(0), elementType(0)); // override(\array_map(0), type(1)); override(\array_filter(0), type(0)); override(\array_reduce(0), elementType(0)); override(\current(0), elementType(0)); override(\reset(0), elementType(0)); override(\end(0), elementType(0)); override(\prev(0), elementType(0)); override(\next(0), elementType(0)); override(\iterator_to_array(0), type(0)); // override( \ServiceLocatorInterface::get(0), // map( [ // "A" => \Exception::class, // \ExampleFactory::EXAMPLE_B => ExampleB::class, // \EXAMPLE_B => \ExampleB::class, // '' => '@|\Iterator', // ]));
function displayLobby($id, $full = false, $ready = false, $rate = false) { $lobby = new lobby($id); $sid = $lobby->lobbyserver($id); $server = new Server($sid); echo '<li class="lobby_panel" data-panel="lobby_tooltip-' . $lobby->id . '"> <img class="map_pic" src="theme/images/maps/' . $lobby->map . '.jpg"> <div class="panel_left"> <h1>' . $lobby->name . '</h1> <span class="date">' . date('g:i a', strtotime($lobby->date)) . '</span> <span class="map">' . $lobby->map . '</span> <ul class="classes"> <li><img src="theme/images/class/scout.png" height="18"></li> <li><img src="theme/images/class/soldier.png" height="18"></li> <li><img src="theme/images/class/demo.png" height="18"></li> <li><img src="theme/images/class/heavy.png" height="18"></li> <li><img src="theme/images/class/sniper.png" height="18"></li> <li><img src="theme/images/class/medic.png" height="18"></li> </ul> </div> <div class="panel_right"> <span class="skillevel skill_higher">Division ' . $lobby->division . '</span> <span class="matchtype">' . type($lobby->type) . '</span> <span class="playercount"><span class="currentplayers">' . countPlayers($lobby->id) . '</span>/<span class="maxplayers">' . 2 * teamplayers($lobby->type) . '</span></span> </div> </li>'; if ($full) { echo '<li class="lobby_tooltip_big" id="lobby_tooltip:' . $lobby->id . '">'; } else { echo '<li class="lobby_tooltip" id="lobby_tooltip:' . $lobby->id . '">'; } echo ' <ul class="blue_players"> <li class="teamname blu">BLU</li>'; if (!$ready && !$rate) { echo $lobby->players_blu; } if ($ready && !$rate) { echo displayLobbyPlayers($lobby->id, $lobby->type, 1, true, false); } if (!$ready && $rate) { echo displayLobbyPlayers($lobby->id, $lobby->type, 1, false, true); } echo ' </ul> <ul class="red_players"> <li class="teamname red">RED</li>'; if (!$ready && !$rate) { echo $lobby->players_red; } if ($ready && !$rate) { echo displayLobbyPlayers($lobby->id, $lobby->type, 2, true, false); } if (!$ready && $rate) { echo displayLobbyPlayers($lobby->id, $lobby->type, 2, false, true); } echo ' </ul>'; if ($full) { echo ' <h1 style="margin-top: 10px; margin-right: 5px;">Spectators:</h1> <ul class="spec_players" style="margin-top: 10px; float: left;">' . $lobby->players_spec . ' </ul><h1 style="margin-top: 10px; margin-right: 5px; clear: left;">Info:</h1> <ul style="margin-top: 10px; float: left;"> <li>Lobby started at 14:23 and has now been running for <span class="time_run">13</span> minutes.</li> </ul> </li>'; } else { echo '<div class="lobby_info"> <h1>Gameserver</h1> ' . $server->showServer() . '' . ($_SESSION['id'] ? '<div class="button join" onclick="joinGame(' . $lobby->id . ')">Join</div>' : '') . ' </div>'; } }
/** * Converts a variable to its string value. * ```php * toString(53)); // '53' * toString(true)); // 'true' * toString(false)); // 'false' * toString(null)); // 'null' * toString('Hello World')); // '"Hello World"' * toString([])); // '[]' * toString(new \stdClass)); // '{}' * toString(function(){})); // '[Function]' * toString(Error::of('Ooops'))); // '[Error: Ooops]' * toString(fopen('php://temp', 'r'))); // '[Resource]' * toString(['hi', 'hello', 'yo'])); // '["hi", "hello", "yo"]' * toString([ * 'object' => Stream::of(null), * 'numbers' => [1, 2, 3], * 'message' * ]); // '{object: Stream(Null), numbers: [1, 2, 3], 0: "message"]' * ``` * * @signature * -> String * @param mixed $something * @return string */ function toString() { $toString = function ($something) { switch (type($something)) { case 'String': return "\"{$something}\""; break; case 'Boolean': return $something ? 'true' : 'false'; break; case 'Null': return 'null'; break; case 'Number': return (string) $something; break; case 'List': return '[' . join(', ', map(toString(), $something)) . ']'; break; case 'Error': case 'Stream': return $something->__toString(); case 'Object': case 'Array': return '{' . join(', ', map(function ($pair) { return $pair[0] . ': ' . toString($pair[1]); }, toPairs($something))) . '}'; default: return '[' . type($something) . ']'; } }; return apply(curry($toString), func_get_args()); }
function edytor() { ob_end_clean(); echo ' <!DOCTYPE html> <html> <head> <title>Edytowanie</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" type="text/css" href="css/apigui.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <style type="text/css"> * { margin:0; } html,body { width:auto; min-width:0; overflow:hidden; } body { background:#60d4ff; } #header { padding-top:5px; background:#FFF; box-shadow:0px 0px 5px #CCC; } #content { color:#FFF; margin:0; } #image { position:absolute; z-index:-2; opacity:0.05; width:100%; } td, th { padding:3px; font-size:16px; text-shadow:1px 1px 0px #4190ad; color:#FFF; } th { font-weight:bold; font-size:16px !important; font-family:Arial; } td input { font-size:16px !important; } #save { position:absolute; bottom:0; left:0; background:#fafafa; padding:20px; width:100%; } .notify_div, #notify { width:360px !important; text-align:center; color:#2c2c2c; text-shadow:#fffc7d; } #notify { background:#fffec4; border-color:#fffc80; margin-left:-180px; } </style> </head> <body> <div id="apigui"> '; $query = mysql_query("SELECT * FROM `tentego_img` WHERE `id`=" . $_GET['id']); if (mysql_num_rows($query)) { if (isset($_POST['save'])) { if (mysql_query("UPDATE `tentego_img` SET `title`='" . htmlspecialchars($_POST['title'], ENT_QUOTES) . "', `cat`='" . $_POST['cat'] . "', `date`='" . $_POST['date'] . "', `src`='" . $_POST['src'] . "', `type`='" . $_POST['type'] . "', `source`='" . htmlspecialchars($_POST['source'], ENT_QUOTES) . "' WHERE `id`=" . $_GET['id'])) { $query = mysql_query("SELECT * FROM `tentego_img` WHERE `id`=" . $_GET['id']); kernel::make_notify("Zapisano."); } else { kernel::make_notify("Bład podczas zapisu."); } } $img = mysql_fetch_array($query); $date = new DateTime($img['date']); function type($pattern, $array) { $type = array('Obrazek' => 'img', 'YouTube.com' => 'youtube', 'Vimeo' => 'vimeo'); $return = NULL; foreach ($type as $name => $value) { $text = str_replace("#NAME#", $name, $pattern); if ($array['type'] == $value) { $text = str_replace("#SELECTED#", ' selected="selected"', $text); } else { $text = str_replace("#SELECTED#", NULL, $text); } $text = str_replace("#TYPE#", $value, $text); $return .= $text; } return $return; } function category($pattern, $value) { $return = NULL; $query = mysql_query("SELECT * FROM `tentego_img_cat`"); while ($cat = mysql_fetch_array($query)) { $text = str_replace("#NAME#", $cat['name'], $pattern); if ($cat['id'] == $value) { $text = str_replace("#SELECTED#", ' selected="selected"', $text); } else { $text = str_replace("#SELECTED#", NULL, $text); } $text = str_replace("#TYPE#", $cat['id'], $text); $return .= $text; } return $return; } switch ($img['type']) { case 'img': $thumb = '?go=manager&feature=thumb&img=../' . $this->img . '/' . $img['src']; break; case 'youtube': parse_str(parse_url($img['src'], PHP_URL_QUERY), $src); $thumb = 'http://i1.ytimg.com/vi/' . $src['v'] . '/hqdefault.jpg'; break; case 'vimeo': $url = parse_url($img['src'], PHP_URL_PATH); $xml = simplexml_load_file("http://vimeo.com/api/v2/video" . $url . ".xml"); $thumb = $xml->video->thumbnail_large; break; } echo '<form method="post" action="?go=manager&feature=edit&id=' . $img['id'] . '">'; echo ' <div id="content"> <div style="width:100%; height:170px; background:url(' . $thumb . ') no-repeat center"></div> <table> <tr> <th>Tytuł:</th> <td><input type="text" name="title" value="' . $img['title'] . '" /></td> </tr> <tr> <th>Data:</th> <td><input type="text" name="date" value="' . $date->format('Y-m-d H:i:s') . '" /></td> </tr> <tr> <th>Adres:</th> <td><input type="text" name="src" value="' . $img['src'] . '" /></td> </tr> <tr> <th>Kategoria:</th> <td> <select name="cat"> ' . category('<option value="#TYPE#"#SELECTED#>#NAME#</option>', $img['cat']) . ' </select> </td> </tr> <tr> <th>Typ:</th> <td> <select name="type"> ' . type('<option value="#TYPE#"#SELECTED#>#NAME#</option>', $img) . ' </select> </td> </tr> <tr> <th>Źródło:</th> <td><input type="text" name="source" value="' . $img['source'] . '" /></td> </tr> </table> <div id="save"><input type="submit" name="save" value="Zapisz zmiany" /></div> </div> '; echo '</form>'; } echo ' </div> <div id="notify"></div> </body> </html> '; if (kernel::get_notify(NULL, 1) > 0) { echo '<script type="text/javascript"> $(document).ready(function(){ $("#notify").show().html(\''; echo kernel::get_notify(NULL, 0, "<div class=\"notify_div\">#CONTENT#</div>"); echo '\').animate({"top":"-15px"}, 500); setTimeout(function(){ $("#notify").fadeOut() }, 30000); $("#notify").click(function() { $(this).fadeOut(); }); }); </script>'; } kernel::destroy_notify(); exit; }
function SelectionGenerate($wpName, $queries, $attMap) { //echo PHP_EOL . '/*' . PHP_EOL; //print_r($wpName); //print_r($queries); //print_r($attMap); //echo PHP_EOL . '*/' . PHP_EOL; ?> // module specific headers to allow separate compilation #include "GLAData.h" #include "Errors.h" //+{"kind":"WPF", "name":"Pre-Processing", "action":"start"} extern "C" int SelectionPreProcessWorkFunc_<?php echo $wpName; ?> (WorkDescription& workDescription, ExecEngineData& result) { SelectionPreProcessWD myWork; myWork.swap(workDescription); QueryExitContainer& queries = myWork.get_whichQueryExits(); QueryToGLASContMap & requiredStates = myWork.get_requiredStates(); QueryToGLAStateMap constStates; <?php cgDeclareQueryIDs($queries); ?> <?php foreach ($queries as $query => $info) { $gf = $info['gf']; if (!is_null($gf) && $gf->has_state()) { $state = $gf->state(); if ($state->configurable()) { $carg = $info['cargs']; echo ' // JSON Configuration for query ' . queryName($query) . PHP_EOL; $carg->init(); echo PHP_EOL; } // if gf const state is configurable } // if gf has state } //foreach query ?> FOREACH_TWL(iter, queries) { <?php foreach ($queries as $query => $val) { ?> if( iter.query == <?php echo queryName($query); ?> ) { <?php if ($val['gf'] !== null) { // This is a generalized filter $gf = $val['gf']; $given_states = $val['states']; if ($gf->has_state()) { $cstArgs = []; $state = $gf->state(); // If the state is configurable, give it the JSON carg if ($state->configurable()) { $carg = $query['cargs']; $cstArgs[] = $carg->name(); } // if gf state is configurable if (\count($given_states) > 0) { ?> FATALIF(!requiredStates.IsThere(<?php echo queryName($query); ?> ), "No required states received for query that declared required states"); GLAStateContainer& givenStates = requiredStates.Find(<?php echo queryName($query); ?> ); givenStates.MoveToStart(); GLAPtr reqTemp; <?php foreach ($givenStates as $gs) { $cstArgs[] = $gs->name(); ?> // Extract state from waypoint[<?php echo $gs->waypoint(); ?> ] <?php echo $gs->type(); ?> * <?php echo $gs->name(); ?> = nullptr; reqTemp.Swap(givenStates.Current()); FATALIF( reqTemp.get_glaType() != <?php echo $gs->type()->cHash(); ?> , "Got different type than expected for required state of type <?php echo $gs > type(); ?> "); <?php echo $gs->name(); ?> = (<?php echo $gs->type(); ?> *) reqTemp.get_glaPtr(); reqTemp.swap(givenStates.Current()); givenStates.Advance(); <?php } // foreach given state } // if we have given states $cstStr = \count($cstArgs) > 0 ? '(' . implode(', ', $cstArgs) . ')' : ''; ?> <?php echo $state; ?> * temp = new <?php echo $state; echo $cstStr; ?> ; GLAPtr newPtr( <?php echo $state->cHash(); ?> , (void *) temp ); QueryID qryID = <?php echo queryName($query); ?> ; constStates.Insert(qryID, newPtr); <?php } // if gf has state } // if( $val['gf'] !== null ) ?> } // if <?php echo queryName($query); ?> is current query <?php } // foreach query ?> } END_FOREACH; SelectionPreProcessRez myRez( constStates ); myRez.swap(result); return WP_PREPROCESSING; // for PreProcess } //+{"kind":"WPF", "name":"Pre-Processing", "action":"end"} //+{"kind":"WPF", "name":"Process Chunk", "action":"start"} extern "C" int SelectionProcessChunkWorkFunc_<?php echo $wpName; ?> (WorkDescription &workDescription, ExecEngineData &result) { // go to the work description and get the input chunk SelectionProcessChunkWD myWork; myWork.swap (workDescription); Chunk &input = myWork.get_chunkToProcess (); QueryToGLAStateMap& constStates = myWork.get_constStates(); PROFILING2_START; QueryIDSet queriesToRun = QueryExitsToQueries(myWork.get_whichQueryExits ()); <?php cgDeclareQueryIDs($queries); cgAccessColumns($attMap, 'input', $wpName); // Declare the constants needed by the filters and synth expressions. foreach ($queries as $query => $val) { ?> // Constants for query <?php echo queryName($query); ?> : <?php $filters = $val['filters']; $synths = $val['synths']; cgDeclareConstants($filters); cgDeclareConstants($synths); } // foreach query ?> // prepare bitstring iterator Column inBitCol; BStringIterator queries; input.SwapBitmap (queries); // creating storage for syhthesized attributes <?php foreach ($queries as $query => $val) { $synList = $val['synths']; foreach ($synList as $att => $syn) { ?> MMappedStorage <?php echo attStorage($att); ?> ; Column <?php echo attCol($att); ?> (<?php echo attStorage($att); ?> ); <?php echo attIteratorType($att); ?> colI_<?php echo $att; ?> (<?php echo attCol($att); ?> ); <?php echo attType($att); ?> <?php echo $att; ?> ; <?php } // foreach synthesized attribute } // foreach query ?> <?php foreach ($queries as $query => $val) { $givenStates = $val['states']; $gf = $val['gf']; $cargs = $val['cargs']; grokit_assert($gf !== null || count($givenStates) == 0, 'We were given states for query ' . $query . ' when we have no GF!'); if (!is_null($gf) && $gf->has_state()) { $state = $gf->state(); $stateName = 'cst_state_' . queryName($query); $constMod = $state->mutable() ? '' : 'const '; ?> // Extracting constant state for query <?php echo queryName($query); ?> FATALIF(!constStates.IsThere(<?php echo queryName($query); ?> ), "No constant state found for query <?php echo queryName($query); ?> ."); <?php echo $constMod; echo $state; ?> * <?php echo $stateName; ?> = nullptr; { GLAState& curState = constStates.Find(<?php echo queryName($query); ?> ); GLAPtr tmp; tmp.swap(curState); FATALIF( tmp.get_glaType() != <?php echo $state->cHash(); ?> , "Got different type than expected for constant state of type <?php echo $state; ?> "); <?php echo $stateName; ?> = (<?php echo $constMod; echo $state; ?> *) tmp.get_glaPtr(); tmp.swap(curState); } <?php } // if gf requires constant state if ($gf !== null) { $ctrArgs = []; if ($gf->configurable()) { echo ' // JSON initialiser for query ' . queryName($query) . PHP_EOL; $cargs->init(); echo PHP_EOL; $ctrArgs[] = $cargs->name(); } if ($gf->has_state()) { $ctrArgs[] = '*' . $stateName; } $ctrStr = \count($ctrArgs) > 0 ? '(' . implode(', ', $ctrArgs) . ')' : ''; ?> // Construct GF for query <?php echo queryName($query); ?> <?php echo $gf->value(); ?> <?php echo queryName($query); ?> _state<?php echo $ctrStr; ?> ; <?php } // if we have a GF } // foreach query ?> MMappedStorage bitStore; Column outBitCol(bitStore); BStringIterator outQueries (outBitCol, queriesToRun); #ifdef PER_QUERY_PROFILE <?php foreach ($queries as $query => $val) { ?> int64_t n_tuples_<?php echo queryName($query); ?> = 0; <?php } // foreach query ?> #endif // PER_QUERY_PROFILE int64_t numTuples = 0; while (!queries.AtEndOfColumn ()) { ++numTuples; QueryIDSet qry; qry = queries.GetCurrent(); qry.Intersect(queriesToRun); queries.Advance(); //selection code for all the predicates <?php cgAccessAttributes($attMap); foreach ($queries as $query => $val) { $gf = $val['gf']; $filters = $val['filters']; $synths = $val['synths']; $stateName = queryName($query) . '_state'; $filterVals = array_map(function ($expr) { return '(' . $expr . ')'; }, $filters); if ($gf === null) { // Simple set of expressions. if (\count($filterVals) > 0) { $selExpr = implode(' && ', $filterVals); } else { $selExpr = 'true'; } } else { // We have a GF $selExpr = "{$stateName}.Filter(" . implode(', ', $filterVals) . ")"; } ?> // do <?php echo queryName($query); ?> : <?php foreach ($synths as $att => $syn) { ?> <?php echo attType($att); ?> <?php echo $att; ?> ; <?php } // foreach synthesized attribute ?> if( qry.Overlaps(<?php echo queryName($query); ?> ) ) { #ifdef PER_QUERY_PROFILE ++numTuples_<?php echo queryName($query); ?> ; #endif // PER_QUERY_PROFILE <?php cgDeclarePreprocessing($filters, 2); ?> if( <?php echo $selExpr; ?> ) { // compute synthesized <?php cgDeclarePreprocessing($synths, 3); foreach ($synths as $att => $expr) { ?> <?php echo $att; ?> = <?php echo $expr; ?> ; <?php } //foreach synthesized attribute ?> } else { qry.Difference(<?php echo queryName($query); ?> ); } } <?php foreach ($synths as $att => $syn) { ?> colI_<?php echo $att; ?> .Insert(<?php echo $att; ?> ); colI_<?php echo $att; ?> .Advance(); <?php } // foreach synthesized attribute } // foreach query ?> outQueries.Insert(qry); outQueries.Advance(); <?php cgAdvanceAttributes($attMap); ?> } // while we still have tuples remaining // finally, if there were any results, put the data back in the chunk <?php cgPutbackColumns($attMap, 'input', $wpName); foreach ($queries as $query => $val) { $synths = $val['synths']; ?> if (<?php echo queryName($query); ?> .Overlaps(queriesToRun)) { <?php foreach ($synths as $att => $expr) { ?> colI_<?php echo $att; ?> .Done(<?php echo attCol($att); ?> ); input.SwapColumn(<?php echo attCol($att); ?> , <?php echo attSlot($att); ?> ); <?php } //foreach synthesized attribute ?> } // If <?php echo queryName($query); ?> overlaps queriesToRun <?php } // foreach query ?> // put in the output bitmap outQueries.Done (); input.SwapBitmap (outQueries); // Finish performance counters PROFILING2_END; PCounterList counterList; PCounter totalCnt("tpi", numTuples, "<?php echo $wpName; ?> "); counterList.Append(totalCnt); PCounter tplOutCnt("tpo", numTuples, "<?php echo $wpName; ?> "); counterList.Append(tplOutCnt); #ifdef PER_QUERY_PROFILE <?php foreach ($queries as $query => $val) { $filters = $val['filters']; ?> if( <?php echo queryName($query); ?> .Overlaps(queriesToRun)) { PCounter cnt("<?php echo queryName($query); ?> ", numTuples_<?php echo queryName($query); ?> , "<?php echo $wpName; ?> "); counterList.Append(cnt); } <?php } // foreach query ?> #endif // PER_QUERY_PROFILE PROFILING2_SET(counterList, "<?php echo $wpName; ?> "); ChunkContainer tempResult (input); tempResult.swap (result); return WP_PROCESS_CHUNK; // For Process Chunk } //+{"kind":"WPF", "name":"Process Chunk", "action":"end"} <?php }
echo "</select></td></tr>\n"; echo "<tr><td align=right>" . $t->translate("New Type Description") . " (255):</td><td><input type=\"TEXT\" name=\"new_description\" size=40 maxlength=255>\n"; echo "</td></tr>\n"; echo "<tr><td> </td>\n"; echo "<td><input type=\"submit\" value=\"" . $t->translate("Change") . "\">"; echo "</td></tr>\n"; echo "</form>\n"; echo "</table>\n"; echo "<BR>\n"; // Delete Type $bs->box_strip($t->translate("Delete Type")); echo "<form action=\"" . $sess->url("instyp.php") . "\" method=\"POST\">\n"; echo "<table border=0 cellspacing=0 cellpadding=3 width=100%>\n"; echo "<tr><td align=right width=30%>" . $t->translate("Type") . ":</td><td width=70%>\n"; echo "<select name=\"type\">\n"; type(""); // We select the first one to avoid having a blank line echo "</select></td></tr>\n"; echo "</td></tr>\n"; echo "<tr><td> </td>\n"; echo "<input type=\"hidden\" name=\"del_type\" value=\"warning\">\n"; echo "<td><input type=\"submit\" value=\"" . $t->translate("Delete") . "\">"; echo "</td></tr>\n"; echo "</form>\n"; echo "</table>\n"; $bx->box_body_end(); $bx->box_end(); } ?> <!-- end content -->
$result['card_id'] = $user['card_id']; $result['authorize_data'] = $user['authorize_data']; $result['authorize_email'] = $user['authorize_email']; } } } $data[] = $result; } $results = $data; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Backoffice " . $site_title)->setLastModifiedBy("Backoffice " . $site_title)->setTitle("Listagem de utilizadores")->setSubject("Listagem de utilizadores")->setDescription("Listagem de utilizadores"); $objPHPExcel->getActiveSheet()->setTitle('Simple'); $line = 1; $letter = 0; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($letters[$letter++] . $line, 'link')->setCellValue($letters[$letter++] . $line, 'tipo')->setCellValue($letters[$letter++] . $line, 'tipo social')->setCellValue($letters[$letter++] . $line, 'votos')->setCellValue($letters[$letter++] . $line, 'nome')->setCellValue($letters[$letter++] . $line, 'email')->setCellValue($letters[$letter++] . $line, 'telefone')->setCellValue($letters[$letter++] . $line, 'cartão continente')->setCellValue($letters[$letter++] . $line, 'autorizou dados')->setCellValue($letters[$letter++] . $line, 'autorizou envio de email')->setCellValue($letters[$letter++] . $line, 'estado')->setCellValue($letters[$letter++] . $line, 'data de criação'); if ($results != null) { foreach ($results as $row) { $letter = 0; $line++; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($letters[$letter++] . $line, "http://" . $_SERVER['SERVER_NAME'] . str_replace('/backoffice', '', $path) . '/#galeria/' . $row['slug'])->setCellValue($letters[$letter++] . $line, itemType($row['type']))->setCellValue($letters[$letter++] . $line, type($row['social_id']))->setCellValue($letters[$letter++] . $line, $row['votes'])->setCellValue($letters[$letter++] . $line, $row['name'])->setCellValue($letters[$letter++] . $line, $row['email'])->setCellValue($letters[$letter++] . $line, $row['phone'])->setCellValue($letters[$letter++] . $line, $row['card_id'])->setCellValue($letters[$letter++] . $line, intval($row['authorize_data']) ? "Sim" : "Não")->setCellValue($letters[$letter++] . $line, intval($row['authorize_email']) ? "Sim" : "Não")->setCellValue($letters[$letter++] . $line, intval($row['status']) ? "Ativo" : "Inativo")->setCellValue($letters[$letter++] . $line, $row['create_date']); } } // Redirect output to a client’s web browser (Excel5) header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="' . date('Y-m-d H:i') . '_continentetv.xls"'); header('Cache-Control: max-age=1'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); } catch (Exception $e) { echo $e->getMessage(); }
} if (strstr($file, '.txt') != NULL) { return 4; } if (strstr($file, '.zip') != NULL || strstr($file, '.rar') != NULL) { return 5; } if (strstr($file, '.png') != NULL || strstr($file, '.jpg') != NULL) { return 6; } return 0; } $files = explode(';', $email['attachment']); $file_type = array(); for ($i = 0; $i < count($files) - 1; $i++) { $file_type[] = type($files[$i]); } //print_r(count($files)); ?> <input id="filecount" class="hidden" value="<?php echo count($files) - 1; ?> " /> <input id="filetype" class="hidden" value="<?php for ($i = 0; $i < count($files) - 1; $i++) { echo $file_type[$i] . ';'; } ?> " /> <input id="filelinkfield" class="hidden" value="<?php echo $email['attachment'];
$modpage = '&type=other'; $d_where = 'WHERE data_type = 3'; $tpl->assign('other_curent', 'font-weight: bold;'); $this_menu .= ' | Other'; } else { $modpage = ''; $d_where = 'WHERE data_type = 1'; $tpl->assign('img_curent', 'font-weight: bold;'); $this_menu .= ' | Ảnh'; } $tpl->assign(array('img_total' => @mysql_num_rows(@mysql_query("SELECT id FROM cnt_datas WHERE data_type = 1")), 'media_total' => @mysql_num_rows(@mysql_query("SELECT id FROM cnt_datas WHERE data_type = 2")), 'other_total' => @mysql_num_rows(@mysql_query("SELECT id FROM cnt_datas WHERE data_type = 3")))); $d_start = ($current_page - 1) * get_option('paging'); $total_d = @mysql_num_rows(@mysql_query("SELECT id FROM cnt_datas " . $d_where . "")); $data_list = @mysql_query("SELECT * FROM cnt_datas " . $d_where . " ORDER BY id DESC LIMIT " . $d_start . "," . get_option('paging')); while ($ldata = @mysql_fetch_array($data_list)) { $icon = $ldata['data_type'] == 1 ? $ldata['data_thumb'] : '../cnt-data/javascripts/editor/icons/' . type($ldata['data_url']) . '.png'; $tpl->assign(array('file_id' => $ldata['id'], 'file_name' => $ldata['data_name'], 'file_icon' => $icon, 'file_desc' => $ldata['data_info'], 'file_time' => formatTime($ldata['data_time'], 1))); $tpl->parse('file_list'); } $tpl->assign('ld_paging', paging(get_option('paging'), $current_page, $total_d, 'index.php?m=5', $modpage . '&page=', false)); break; case '1': $edata = @mysql_fetch_array(@mysql_query("SELECT data_name, data_info FROM cnt_datas WHERE id = " . $_GET['id'])); $tpl->assign(array('edata_id' => $_GET['id'], 'edata_name' => $edata['data_name'], 'edata_desc' => $edata['data_info'])); $this_menu .= ' | Sửa thông tin'; break; } break; case '6': $this_menu = '| Liên kết'; if ($_GET['id'] > 0) {
$data = []; foreach ($row as $key => $value) { //if ($key==='sourceip' && inet_pton($value)!==FALSE) { // $data[sprintf('"%s"', $key)] = inet_pton($value); //} else // $data[sprintf('"%s"', $key)] = $value; if ($key === 'sourceip') { if (is_ipv4($value)) { $data[sprintf('"%s"', "type")] = 'ipv4'; $data[sprintf('"%s"', "cidr")] = 32; } if (is_ipv6($value)) { $data[sprintf('"%s"', "type")] = 'ipv6'; $data[sprintf('"%s"', "cidr")] = 128; } if (type($value) === 'unknown') { exit(ArrestDB::Reply(ArrestDB::$HTTP[411])); } if (inet_pton($value) !== FALSE) { $data[sprintf('"%s"', $key)] = inet_pton($value); } } else { //$data[sprintf('"%s"', $key)] = $value; exit(ArrestDB::Reply(ArrestDB::$HTTP[412])); } } // end foreach $data[sprintf('"%s"', "expiretime")] = '9999-12-31 23:59:59'; $data[sprintf('"%s"', "country")] = 'UNK'; $data[sprintf('"%s"', "hits")] = 0; $data[sprintf('"%s"', "comment")] = 'mysql-api';
} function type() { include "conf.php"; $district = $_POST['district']; $mineral = $_POST['mineral']; $query = "SELECT * FROM rokka ORDER by OGR_FID "; $result = mysqli_query($connect, $query); return $result; } if ($district != "" and $mineral != "") { $result = dist(); } elseif ($district != "" or $mineral != "") { $result = mineral(); } else { $result = type(); } if ($result->num_rows > 0) { echo '<table class="TFtable table-striped table-border: 1px solid black; table-hover">'; echo "<TR><TD width='40' border: 1px solid black;><h3>Zone<h3></TD><TD width='40'><h3>District<h3></TD><TD width='50'><h3>Location<h3></TD><TD><h3>Mineral<h3></TD><TD Width='80' border=5px><h3>Area<h3></TD><TD><h3>X <h3></TD><TD><h3>XX <h3></TD><TD><h3>Y <h3></TD><TD><h3>YY <h3></TD><TD width='40'><h3>TopoSheet<h3></TD><TD width='40'><h3>Remarks<h3></TD><TD width='40'><h3>Map<h3></TD></TR>"; while ($row = $result->fetch_assoc()) { $x = $row["x"]; $xx = $row["xx"]; $y = $row["y"]; $yy = $row["yy"]; echo "<tr><td width = '40' border: 1px solid black;>"; echo $row["zone"]; // echo "<a id = \"mineSite\" href = \"javascript:showOnMap(" . $x . "," . $y . ");\">" . $row["zone"] . "</a>\n"; echo "</td><td width = '40' border: 1px solid black;>"; echo $row["district"]; echo "</td><td width = '40' border: 1px solid black;>";
$APPLICATION->SetTitle($ar_sect_sport['NAME']); if($ar_sect_sport['IPROPERTY_VALUES']['SECTION_META_DESCRIPTION']!='') $APPLICATION->SetPageProperty('Description', ''.$ar_sect_sport['IPROPERTY_VALUES']['SECTION_META_DESCRIPTION']); ?> <? $category_section = cat_section($whe_city,$iblok_id); uasort($category_section, "sort_c"); ?> <? $type_c = array(); $type_a = array(); foreach($category_section as $item) { $type = type($item,$whe_city,$iblok_id); uasort($type, "sort_p"); foreach($type as $i) { if (in_array($i['type'], $type_c, true) != true) { array_push($type_c ,$i); } } } $type_c= array_map("unserialize", array_unique( array_map("serialize", $type_c) )); uasort($type_c, "sort_p"); ?> <div class="filter-category iselect" > <div class="iselect-header">Вид спорта</div> <ul class="iselect-option">
break; } //end switch /* 2. sanitize description */ $description = filter_var($_POST['description'], FILTER_SANITIZE_SPECIAL_CHARS); $description = filter_var($description, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_HIGH); //$description = make_safe( $description ); /* 3. sanitize IP */ $ip = $_POST['ip']; if (!filter_var($ip, FILTER_VALIDATE_IP)) { error_log("{$time} [{$script_name}] [rtbh] [{$remote_addr}-{$myuser}] [IP {$ip} NOT valid ]\n", 3, $log_file); $error = " IP not valid "; } /* check what type of IP we're dealing with */ if ($error === "") { $type = type($ip); if ($type === "unknown") { error_log("{$time} [{$script_name}] [rtbh] [{$remote_addr}-{$myuser}] [IP {$ip} unknown, possible private range ]\n", 3, $log_file); $error = " IP unknown "; } } if ($error === "") { if (valid_ipv4_host($ip)) { $type = "ipv4"; $cidr = 32; } elseif (valid_ipv6_host($ip)) { $type = "ipv6"; $cidr = 128; /* compress ipv6 to short form & lowercase */ $ip = compress($ip); } else {
/** * Return the given table with its alias being cleared * * @param array|string $table * * @return string * * @throws IcingaException In case $table is not of a supported type */ protected function clearTableAlias($table) { if (is_string($table)) { return $table; } if (is_array($table)) { return reset($table); } throw new IcingaException('Table alias handling for type "%s" is not supported', type($table)); }
public function render() { if (!$this->items) { return $this->value; } if ($this->value == '') { return ''; } $result = $this->value; foreach ($this->items as $name => $value) { if (is_object($value) && type($value) == '.db.statement') { $result = str_replace('{' . $name . '}', $value->render(), $result); } else { if (is_object($value) && method_exists($value, '__toString')) { $value = strval($value); $result = str_replace('{' . $name . '}', id($value), $result); } else { $result = str_replace('{' . $name . '}', id($value), $result); } } } return preg_replace("/{[A-Za-z0-9_\\]\\[]*}/", "", $result); }
?> <tr id="item-<?php echo $item['id']; ?> "> <td><img width="150" src="<?php echo $item['image']; ?> " class="img-thumbnail" /></td> <td><?php echo $item['name']; ?> </td> <td><?php echo type($item['social_id']); ?> <?php echo $item['social_id'] == 3 ? $item['instagram'] == 1 ? "<span class='label label-success'>Utilizador validado</span>" : "<span class='label label-danger'>Utilizador não validado</span>" : ""; ?> </td> <td><?php echo $item['votes']; ?> </td> <td><?php echo $item['create_date']; ?> </td> <td><a class="btn btn-primary" href="<?php
}]; $values = [1, 1.0, "1", TRUE, FALSE, NULL, [], new StdClass(), fopen("data:text/plain,foobar", "r")]; function type($value) { if (is_float($value)) { return "float"; } else { if (is_bool($value)) { return $value ? "true" : "false"; } else { if (is_null($value)) { return "null"; } else { return gettype($value); } } } } foreach ($functions as $type => $function) { echo PHP_EOL, "Testing '{$type}' typehint:", PHP_EOL; foreach ($values as $value) { $errored = false; echo PHP_EOL . "*** Trying ", type($value), " value", PHP_EOL; try { var_dump($function($value)); } catch (TypeError $e) { echo "*** Caught " . $e->getMessage() . PHP_EOL; } } } echo PHP_EOL . "Done";