', '

', '

', chr(13)), array('', '', chr(10), ''), $t)); $t = str_replace( array(chr(10).chr(10), '<b>', '</b>', '<i>', '</i>'), array(chr(10), '', '', '', ''), htmlspecialchars($t)); return(nl2br($t)); } #http://web.archive.org/web/20190317152852im_/http://ludumdare.com/compo/wp-content/uploads/2018/08/SDL2-joystick-interrogator-2.0.gif function ld_user_from_link($l) { if(substr($l, -1) == '/') $l = substr($l, 0, -1); $seg = explode('/', $l); return($seg[sizeof($seg)-1]); } function ld_user_from_data($d) { if($d['author_link']) return(ld_user_from_link($d['author_link'])); } function ld_format_username($uds) { return(''.htmlspecialchars($uds['us_name']).''); } function InitEnvironment() { spl_autoload_register(function ($class) { include_once('lib/'.strtolower($class).'.php'); }); $_SERVER["HTTP_SOURCE"] = $_SERVER["REMOTE_ADDR"]; $_SERVER["HTTP_X_FORWARDED_FOR"] = @first($_SERVER["HTTP_X_REAL_IP"], $_SERVER['HTTP_X_FORWARDED_FOR'], $_SERVER['REMOTE_ADDR']); } # makes a Unix timestamp human-friendly, web-trendy and supercool function ageToString($unixDate, $new = 'just now', $ago = 'ago') { if($unixDate == 0) return('-'); $result = ''; $oneMinute = 60; $oneHour = $oneMinute*60; $oneDay = $oneHour*24; $difference = time() - $unixDate; if ($difference < -$oneDay*5) $result = formatDate($unixDate); else if ($difference < -$oneDay) $result = 'in '.round(-$difference/$oneDay).' d '; else if ($difference < -$oneHour) $result = 'in '.round(-$difference/$oneHour).' h '; else if ($difference < 0) $result = 'in '.round(-$difference/$oneMinute).' min '; else if ($difference < $oneMinute) $result = $new; else if ($difference < $oneHour) $result = round($difference/$oneMinute).' min '.$ago; else if ($difference < $oneDay) $result = floor($difference/$oneHour).' h '.$ago; else if ($difference < $oneDay*5) $result = date(cfg('service/dateformat-week', 'D · H:i T'), $unixDate); else if ($difference < $oneDay*365) $result = date(cfg('service/dateformat-year', 'M dS · H:i T'), $unixDate); else $result = date(cfg('service/dateformat', 'd. M Y · H:i T'), $unixDate); return($result); } function diffData($newData, $oldData = array()) { foreach($newData as $k => $v) if($oldData[$k] == $newData[$k]) unset($newData[$k]); return($newData); } function debugOut($a) { print('
');
  ob_start();
  print_r($a);
  print(htmlspecialchars(ob_get_clean()));
  print('
'); } function fail($reason = 'error', $result = array()) { $result['result'] = 'fail'; $result['reason'] = $reason; $result['endpoint'] = URL::$route['locator']; return($result); } function IsOK($result) { return($result['result'] == 'OK'); } function randomItem($a) { return($a[mt_rand(0, sizeof($a)-1)]); } function formatDate($date, $noYear = true) { return(date(cfg('service/dateformat', 'd. M'.($noYear ? '' : ' Y').' · H:i T'), $date)); } function critical($err = 'unknown error') { $bt = debug_backtrace(); $trace = array(); foreach($bt as $t) { unset($t['object']); unset($t['class']); unset($t['type']); unset($t['args']); $trace[] = array_dump($t); } Log::Error($err, $trace); if(cfg('content-mode') == 'json') { print(json_encode(array( 'result' => 'fail', 'reason' => 'server error', 'details' => $err, ))); die(); } else if(cfg('dev')) { print(''); die(); } else { $_REQUEST['route']['error'] = ''; print('[Application Error]'); } } function array_dump($a) { return(str_replace(array('"', '\\'), '', json_encode($a))); } function array_extract($l, $fieldname) { $result = array(); foreach($l as $item) { $result[] = $item[$fieldname]; } return($result); } function array_cull($in, $cullKeys) { if(!is_array($cullKeys)) $cullKeys = array($cullKeys); foreach($cullKeys as $k) unset($in[$k]); return($in); } function car($list) { $result = null; if(is_array($list)) foreach($list as $item) { $result = $item; break; } return($result); } # retrieve a config value (don't use $GLOBALS['config'] directly if possible) function cfg($name, $default = null) { $vr = &$GLOBALS['config']; foreach(explode('/', $name) as $ni) if(is_array($vr)) $vr = &$vr[$ni]; else $vr = ''; if($default == null && is_array($vr)) return($vr); return(first($vr, $default)); } # set a config value function cfgSet($name, $value = null) { $vr = &$GLOBALS['config']; $seg = explode('/', $name); $lastKey = array_pop($seg); if(is_array($seg)) foreach($seg as $ni) { if(!is_array($vr[$ni])) $vr[$ni] = array(); $vr = &$vr[$ni]; } $vr[$lastKey] = $value; return($value); } # clamp value between min and max function clamp($v, $min, $max) { if($v < $min) $v = $min; if($v > $max) $v = $max; return($v); } # dynamic dispatch function dispatch($object, $methodName) { if(is_callable(array($object, $methodName))) { $args = func_get_args(); array_shift($args); array_shift($args); return(call_user_method_array($methodName, $object, $args)); } } # returns the first non-null, non-empty variable passed to it function first(&$fvar) { foreach(func_get_args() as $a) if($a != null && $a != '') return($a); return(''); } # return list of files matching $path function getFileList($path) { $result = array(); foreach(explode("\n", shell_exec('ls '.$path)) as $f) { if($f != '' && substr($f,0,1) != '.') $result[] = $f; } return($result); } # issue a synchronous HTTP post request function httpPost($url, $params = array()) { //open connection $channel = curl_init(); //set the url, number of POST vars, POST data curl_setopt($channel,CURLOPT_URL, $url); curl_setopt($channel,CURLOPT_POST, 1); curl_setopt($channel,CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($channel, CURLOPT_HEADER, 0); curl_setopt($channel, CURLOPT_TIMEOUT, 1); curl_setopt($channel, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($channel); //close connection curl_close($channel); return($result); } function map($list, $applyFunc) { $result = array(); foreach($list as $k => $item) { $d = $applyFunc($item, $k); if($d) $result[] = $d; } return($result); } // cut $cake at the first occurence of $segdiv, returns the slice function nibble($segdiv, &$cake, &$found = false) { $p = strpos($cake, $segdiv); if ($p === false) { $result = $cake; $cake = ''; $found = false; } else { $result = substr($cake, 0, $p); $cake = substr($cake, $p + strlen($segdiv)); $found = true; } return $result; } function startsWith($s, $match) { return(strtolower(substr($s, 0, strlen($match))) == strtolower($match)); } function urls2Links($text, $opt = array()) { $result = ''; while($text != '') { $found = false; $result .= nibble('http', $text, $found); if($found) { $wPos = findNextWhiteSpace($text); $lnk = substr($text, 0, $wPos); $text = substr($text, $wPos); $codeBracketOpenPos = strrpos($result, '['); $codeBracketClosePos = strrpos($result, ']'); if( ($codeBracketClosePos === false || $codeBracketClosePos > $codeBracketOpenPos) && (startsWith($lnk, '://') || startsWith($lnk, 's://'))) { $lnk = 'http'.$lnk; if($opt['callback']) $result .= $opt['callback']($lnk); else { $lnkText = $lnk; if(strlen($lnkText) > 32) $lnkText = substr($lnkText, 0, 20).'...'.substr($lnkText, -12); $result .= ''.htmlspecialchars($lnkText).''; } } else { $result .= 'http'.$lnk.' '; } } } return(trim($result)); } # append any string to the given file function WriteToFile($filename, $content) { $open = fopen($filename, 'a+'); fwrite($open, $content); fclose($open); }
Fatal error: Uncaught Error: Call to undefined function InitEnvironment() in /Code/ludumdata.openfu.com/index.php:23 Stack trace: #0 {main} thrown in /Code/ludumdata.openfu.com/index.php on line 23