/** * Recursive detect DOMText fit $len * Find text and check if that text appending still fit the required len. * @param DOMNode $dom * @param int $len * @param type $buffer */ function getNext($dom, $len, &$buffer = '') { // fulled -> by pass all followed tag if (mb_strlen($buffer) >= $len) { return null; } else { if (get_class($dom) == 'DOMText') { // if tag is text -> try to use this text // still shorter than required $len if (mb_strlen($buffer . $dom->wholeText) < $len) { $buffer .= $dom->wholeText; return $dom; } else { // Get part of this node text fitting the required $len //return null; // try to get part of $part = $len - mb_strlen($buffer); $st = mb_substr($dom->wholeText, 0, $part); $buffer .= $st; return $st; } // node have childs -> check each child } elseif (isset($dom->childNodes) && $dom->childNodes->length > 0) { $i = 0; while ($i < $dom->childNodes->length) { $child = $dom->childNodes->item($i); $ret = getNext($child, $len, $buffer); if ($ret === null || is_string($ret)) { while ($i < $dom->childNodes->length) { $dom->removeChild($dom->childNodes->item($i)); } if (is_string($ret)) { $dom->appendChild(new DOMText($ret . '...')); $i++; } } else { $i++; } } // if all child deleted -> return null node if ($dom->childNodes->length == 0) { return null; } else { return $dom; } // other leaf node (br, img) } else { echo $dom->nodeName; return $dom; } } //TODO image balancing -> 1 image equivalent how many charaters? }
function generateNavibar($page) { $prev = getPrev($page); $next = getNext($page); $prev5 = getPrev($page, 5); $next5 = getNext($page, 5); $page = intval($page); $html = ''; $html .= '<form>'; $html .= createButton($prev5, !doesPageExist("{$prev5}"), '<<'); $html .= createButton($prev, !doesPageExist("{$prev}"), '<'); $html .= "</form>"; $html .= createDropDownMenu($page, getFileCountInDirectory('pages/')); $html .= '<form>'; $html .= createButton($next, !doesPageExist("{$next}"), '>'); $html .= createButton($next5, !doesPageExist("{$next5}"), '>>'); $html .= "</form>"; return $html; }
function showPagination($META, $url, $currentPage, $prevOn, $nextOn, $pageNav) { if ($prevOn) { $pageNav[] = "<a href='" . $url . ($currentPage - 1) . "'>" . getPrev() . "</a>"; } if ($nextOn) { $pageNav[] = "<a href='" . $url . ($currentPage + 1) . "'>" . getNext() . "</a>"; } if (count($pageNav)) { echo "<ul style=\"list-style: none;\">\n<li style=\"float: left;margin-right: 15px;\">" . implode("</li>\n<li style=\"float: left;margin-right: 15px;\">", $pageNav) . "</li>\n</ul><br/>\n"; } }
</div> <div class="next"><?php echo getNext(); ?> </div> </div> <?php echo printAll(); ?> <div class="nextprevbar"> <div class="prev"><?php echo getPrev(); ?> </div> <div class="next"><?php echo getNext(); ?> </div> </div> <?php } else { require_once 'include/pages/_login.php'; } ?> <?php
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); #nclude("GrooveShark_PHP/grooveshark.class.php"); include "assets/includes/sonicflow.php"; #$gs = new GrooveShark(); $failcount = 0; echo "Daemon started.\n"; while (true) { try { $next = getNext(); if ($next[0] == '') { $failcount = 0; sleep(2); } else { $id = $next[0]; $song = $next[1]; $songId = $song->id; if ($song != null) { $failcount = 0; if ($next[2] != CACHE_IN_PROGRESS) { $cmd = "mplayer -cache 8192 /var/www/SonicFlow/assets/songs/" . $id . ".mp3"; passthru($cmd); removeSongFromQueue($id); } } else { echo "\n\nFailed to retrieve URL for {$song->title} by {$song->artist}!\n\n"; $failcount++; if ($failcount >= 3) { fixBadId($id);
<?php if (count($json) == 0) { echo '<a href="#"> <li class="list-group-item">Vazio</li></a>'; } foreach ($json as $atual) { echo '<a href="' . $atual["@Ontology#link"] . '"> <li class="list-group-item">' . $atual["@Ontology#label"] . '</li></a>'; } ?> </ul> </div> <div class="col-lg-3 espacado"> <form action="topicoatual.php" method="get"> <?php $next = getNext($topico); // print_r($next); if (count($next) == 1) { echo "<button type='submit' name= 'selecao' value='" . $next[0]["@Ontology#id"] . "' > Next</button>"; echo $next[0]["@Ontology#label"]; } ?> <input type="hidden" name="modelo" value="<?php echo $modelo; ?> "> </form> </div> </body>
} else { $numConsecutive = 1; } } if ($numPairs < 2) { if ($char === $prev) { $numRepeats++; if ($numRepeats % 2 === 1) { $numPairs++; } } else { $numRepeats = 0; } } $prev = $char; } return $has3Consecutive && $numPairs >= 2; } function getNext($input) { $next = $input; do { $next = increment($next); while (($validLen = strcspn($next, 'iol')) !== strlen($next)) { $next = increment(substr($next, 0, $validLen + 1)) . substr($next, $validLen + 1); } } while (!isValid($next)); return $next; } echo 'Answer: ' . getNext($input) . PHP_EOL;
function bottom($ID_MSG) { echo " <div class = \"sitefooter\">\n"; echo " <img src = \"http://www.turkiball.com/images/evofsportbig.jpg\" alt = \"The Evolution of Sport\" style = \"position: relative; top: 10px;\"> <br>\n"; echo " <h3>\n"; echo " © 2010 Guardian Sports, Ann Arbor, MI<br>\n"; echo " <a class = \"lightbg\" href = \"mailto: contact@turkiball.com\">contact@turkiball.com</a>\n"; echo " </h3>\n"; echo " </div>\n"; echo " <div class = \"allbottom\">\n"; echo " <ul class = \"navbottom\">\n"; if (strpos($filename, 'events')) { $id = 4; $cat = "events"; } elseif (strpos($filename, 'league')) { $id = 8; $cat = "league"; } elseif (strpos($filename, 'other')) { $id = 10; $cat = "other"; } elseif (strpos($filename, 'turkiball') > 20) { $id = 9; $cat = "turkiball"; } else { $id = 0; $cat = ""; } echo " <li><a href = \"http://www.turkiball.com/feed/\">Older Post</a>\n"; echo " <li><a href = \"http://www.turkiball.com/feed/" . $cat . "archive.php\">Archive</a>\n"; echo " <li><a href = \"http://www.turkiball.com/feed/index.php?num=" . getNext($ID_MSG, $id) . "\">Newer Post</a>\n"; echo " </ul>\n"; echo " </div>\n\n"; echo "</div>\n\n"; }
function addMonthlyCol($numMonths, &$dataArray) { //adds a monthly column beginning with January $next = getNext($dataArray, 0); $dataArray[0][$next] = "Date/Time"; $year = date("Y"); for ($i = 0; $i < $numMonths; $i++) { if ($i > 12 && $i % 12 == 0) { //after 12 months, go to next year $year++; } $mm = $i % 12 + 1; $month = date("m/t", strtotime("{$year}-{$mm}")); $next = getNext($dataArray, $i + 1); $dataArray[$i + 1][$next] = "{$month} 23:59:59"; } }
exec("particle call {$photonName} setheight " . $presets[$previousPosition]['height']); } elseif ($cmd == "down" && isset($presets[$nextPosition])) { // Go down one position exec('notify-send -i ' . $presets[$nextPosition]['icon'] . ' "Moving desk to ' . $nextPosition . '"'); exec("particle call {$photonName} setheight " . $presets[$nextPosition]['height']); } elseif (isset($presets[$cmd])) { // go to the preset exec('notify-send -i ' . $presets[$cmd]['icon'] . ' "Moving desk to ' . $cmd . '"'); exec("particle call {$photonName} setheight " . $presets[$cmd]['height']); } } else { if ($standingTime > 0 && $totalTime > 0) { echo " Time Standing: " . convertToHoursMins($standingTime) . " - " . number_format($standingTime / $totalTime * 100, 1) . "%\n"; } if ($sittingTime > 0 && $totalTime > 0) { echo " Time Sitting: " . convertToHoursMins($sittingTime) . " - " . number_format($sittingTime / $totalTime * 100, 1) . "%\n"; } echo " Time at desk: " . convertToHoursMins($totalTime) . "\n\n"; $currentHeight = exec("particle call {$photonName} getheight"); echo " Current Height: " . $currentHeight . "cm\n"; $currentPosition = getClosest($currentHeight, $presets); $previousPosition = getPrevious($currentPosition, $presets); $nextPosition = getNext($currentPosition, $presets); if (!is_null($previousPosition)) { echo " Up Position: " . $previousPosition . " (" . $presets[$previousPosition]['height'] . "cm)\n"; } echo " Current Position: " . $currentPosition . " (" . $presets[$currentPosition]['height'] . "cm)\n"; if (!is_null($nextPosition)) { echo " Down Position: " . $nextPosition . " (" . $presets[$nextPosition]['height'] . "cm)\n"; } }
function translateCommonlabel($template) { global $pagesize, $articleid; $template = str_replace("【#sitename】", getSitename(), $template); $template = str_replace("【#htmltitle】", getHtmltitle(), $template); $template = str_replace("【#copyright】", getCopyright(), $template); $template = str_replace("【#path】", getPath(), $template); $template = str_replace("【#logo】", getLogo(), $template); $template = str_replace("【#chanels】", getChanels(), $template); $template = str_replace("【#childcolumnlist】", getChildcolumnlist(), $template); //网站,栏目,文章关键字 $template = str_replace("【#sitekeywords】", getSitekeywords(), $template); $template = str_replace("【#columnkeywords】", getColumnkeywords(), $template); $template = str_replace("【#articlekeywords】", getArticlekeywords(), $template); $template = str_replace("【#columnname】", getColumnname(), $template); $template = str_replace("【#articleid】", $articleid, $template); $template = str_replace("【#articletitle】", getArticletitle(), $template); $template = str_replace("【#articlecontent】", getArticlecontent(), $template); $template = str_replace("【#date】", getAdddate(), $template); $template = str_replace("【#hits】", getHits(), $template); $template = str_replace("【#author】", getAuthor(), $template); $template = str_replace("【#source】", getSource(), $template); $template = str_replace("【#picurl】", getPicurl(), $template); $template = str_replace("【#pre】", getPre(), $template); $template = str_replace("【#next】", getNext(), $template); $template = str_replace("【#notes】", getNotes(), $template); $template = str_replace("【#commentform】", getCommentform(), $template); //替换自定义字段标签 $template = translateSdefFeildlabel($template); $template = str_replace("【#showpage】", getPage($pagesize), $template); return $template; }
require_once "assets/includes/sonicflow.php"; /* * This will check whether there is a new song yet. * Returns true if there is a new song; otherwise, false. * If this is being called from the now playing page, then it * will return the new song id if there is a new song; otherwise, 0. */ $id_front = $_POST['id_front']; $id_back = $_POST['id_back']; $from = $_POST['from']; if ($from == "queue") { $song_front = getNext(); $song_back = getLast(); $song_front = $song_front[1]; $song_back = $song_back[1]; echo $id_front != $song_front->id || $id_back != $song_back->id; } else { $song_front = getNext(); $song_front = $song_front[1]; if ($id_front != $song_front->id) { $json = getSongJson($song_front); echo $json; } else { echo 0; } } function getSongJson($song) { $arr = array('id' => $song->id, 'title' => $song->title, 'artist' => $song->artist, 'album' => $song->album, 'arturl' => $song->arturl); return json_encode($arr); }
?> <?php if ($paginator->getLastPage() > 1) { ?> <nav class="text-right"> <ul class="pagination"> <?php echo getPrevious($paginator->getCurrentPage(), $paginator->getUrl($paginator->getCurrentPage() - 1)); ?> <?php echo $presenter->getPageRange(1, $paginator->getLastPage()); ?> <?php echo getNext($paginator->getCurrentPage(), $paginator->getLastPage(), $paginator->getUrl($paginator->getCurrentPage() + 1)); ?> </ul> </nav> <?php } ?> <?php function getPrevious($currentPage, $url) { if ($currentPage <= 1) { return '<li class="previous disabled"> <span aria-hidden="true">«</span></li>';
$count = isset($_REQUEST["count"]) ? $_REQUEST["count"] : 0; $buf = ""; $moji = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); $moji = array("あ", "い", "う", "え", "お", "か", "き", "く", "け", "こ"); $moji = array("ア", "イ", "ウ", "エ", "オ", "カ", "キ", "ク", "ケ", "コ"); $c = 0; function getNext() { global $c, $moji; $m = $moji[$c]; $c = ($c + 1) % 10; return $m; } for ($i = 0; $i < $count; $i++) { $buf .= getNext(); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>全角文字列生成サービス</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(function(){ $("input:visible").first().focus(); }); </script> </head> <body>
function doDiscard($msg) { $sid = SID; $redis = getRedis(); $user = getUser(); if (!$user['tableid']) { return false; } $tableid = $user['tableid']; $seatid = $user['seatid']; $seatkey = "seat-{$seatid}"; //check table state $table = getTable(); if (!$table['state']) { return false; } //check state state $seat = $table['seats'][$seatid]; if ($seat['state']) { return false; } //check current if ($table['current'] != $seatid) { return false; } //update seat $seat['state'] = SEAT_STATE_DISCARD; //next $next = getNext($table); $table['seats'][$seatid] = $seat; $table['current'] = $next; $redis->hmset("table:{$tableid}", array($seatkey => json_encode($seat), 'current' => $next)); $router = getRouter(); $router->publish("table:{$tableid}", packMsg('discard', array('sid' => $sid, 'current' => $next))); gameover($table); }