/** callback addType is almost identical to addTemplate. Pass it an array with this arg: *$args['type'] = 'Type_Name'; // you don't need to put brackets around the type name. * And don't precede it with "Type:" either. Just the name, please. */ function addType($content, $args) { if (!is_array($args)) { return $content; } // do nothing extract($args); if ('' == $type) { die("You didn't pass valid parameters to 'addType()'"); } $type = '[[has type::' . $type . ']]'; if (inString($content, $type)) { // don't add the category twice return $content; } $content = trim($content); if ('' == $content) { // this probably means that we're adding a type to a type page without any text at the top $content = $type; } elseif (inString($content, '[[has type:')) { $content = $type; } else { $content .= $type; } // if there isn't already a type... return $content; }
$filearr['filetype'] = $_FILES[$field]['type']; } } } else { if ($gtbl->getSelectMultiple($field)) { if (is_array($_REQUEST[$field])) { $fieldv = implode(",", $_REQUEST[$field]); } else { $fieldv = $_REQUEST[$field]; } } else { $fieldv = $_REQUEST[$field]; if ($fieldv == '') { $fieldv = $hmfield[$field . "_default"]; if ($fieldv == '') { if (inString('int', $hmfield[$field])) { #print __FILE__.": field:[".$field."] type:[".$hmfield[$field]."] is int."; $fieldv = 0; } } } else { if (strpos($fieldv, "<") !== false) { # added by wadelau on Sun Apr 22 22:09:46 CST 2012 if ($fieldInputType == 'textarea') { # allow all html tags except these below $fieldv = str_replace("<script", "<script", $fieldv); $fieldv = str_replace("<iframe", "<iframe", $fieldv); $fieldv = str_replace("<embed", "<embed", $fieldv); } else { $fieldv = str_replace("<", "<", $fieldv); }
} else { $val = 'default'; } ?> <input type="text" form="shuffleFile" name="zoom" value="<?php echo $val; ?> " class="zoomInput" hidden/> <!-- Jquery puts modified zoom value here and it is submitted when shuffle button is pressed--> <span id="zoomVal" class="hidden"><?php echo $val; ?> </span> <!-- keeps the zoom value most recently submitted --> <form id="shuffleFile" action="" method="get"></form> <!-- the form that submits the selctions made on this page --> <?php if ($store['loc'] !== '' && inString('.csv', $store['loc']) == true) { $before = GetFromFile($store['loc']); // grab file to shuffle $timer = microtime(true); // start a timer $after = multiLevelShuffle($before); // run basic shuffles $after = shuffle2dArray($after); // run advanced shuffles $timer = microtime(true) - $timer; // calculate difference since start $timer = round($timer * 1000000, 0); // multiply by 1,000,000 and round $tableTimer = microtime(true); // show the before shuffling version echo '<div class="before"><div id="RF"><h2>Before</h2>';
function dumbFilter($content) { if (inString($content, '[[Category:Robots]]')) { // if the article already has the category... $content = str_replace('[[Category:Robots]]', '', $content); } else { // otherwise... $content .= ' [[Category:Robots]]'; } // add it. return $content; // CRUCIAL. Return the edited content back to wikiFilter(). }
// write newline character } else { $ipFile = fopen($ipPath, 'a'); fputs($ipFile, $ip); // write IP to file fputs($ipFile, PHP_EOL); // write newline character } } #### make a master list of unique user IDs (lowercase and trimmed) foreach ($files as $file) { // check all files // set correct delimiter and skip IP log file if (inString('.txt', $file)) { $delimiter = "\t"; } elseif (inString('.csv', $file)) { $delimiter = ','; } else { continue; } if ($file == $ipFilename) { // skip reading IP file continue; } $current = array(); // clear data from current file before loading next one $current = GetFromFile($folder . $file, false, $delimiter); // read a file presumably containing workers if (!isset($current[0]['WorkerId'])) { // skip files without a 'WorkerID' column $skipped[] = $file;
/** * URL redirect, remedy by wadelau@ufqi.com 09:52 Tuesday, November 24, 2015 */ function redirect($url, $time = 0, $msg = '') { //multi URL addr support ? $url = str_replace(array("\n", "\r"), '', $url); if (!inString('://', $url)) { # relative to absolute path $url = $_SERVER['SERVER_NAME'] . $url; } if ($time < 10) { $time = $time * 1000; } # in case of milliseconds $hideMsg = "<!DOCTYPE html><html><head>"; $hideMsg .= "<meta http-equiv=\"refresh\" content=\"{$time};URL='{$url}'\">"; $hideMsg .= "</head><body>"; # remedy Mon Nov 23 22:03:24 CST 2015 if (empty($msg)) { #$msg = "系统将在{$time}秒之后自动跳转到{$url}!"; $hideMsg = $hideMsg . " <a href=\"" . $url . "\">系统将在{$time}秒之后自动跳转</a> <!-- {$url}!--> ..."; } else { $hideMsg = $hideMsg . $msg; } $hideMsg .= "<script type='text/javascript'>window.setTimeout(function(){window.location.href='" . $url . "';}, " . $time . ");</script>"; $hideMsg .= "</body></html>"; if (!headers_sent()) { // redirect if (1 || 0 === $time) { header("Location: " . $url); print $hideMsg; } else { if (0) { # Refresh in HTTP is non-standard. header("Refresh:{$time};url={$url}"); echo $msg; } } exit; } else { print $hideMsg; exit; } }
continue; } // <title> if ($inPart == true && $includePart && preg_match("/<title/", $line)) { $partStack[] = $line; continue; } // the rest if ($inPart == true) { if ($includePart == false) { continue; } if (preg_match("/(\\s\t)*&([a-z0-9\\.-]+);/", $line, $matches)) { if ($sections) { echo "Including " . $matches[2] . "? "; if ($include = inString($sections, $matches[2])) { echo "YES\n"; } else { echo "NO\n"; } } else { if ($hasReadline) { $include = evaluate(readline("Include " . $matches[2] . "? [NO] ")); } } if ($include == true) { $partStack[] = $line; } } } else { $newFile .= $line;
/** * Determine if the string refers to an audio or image file and generate tags. * @param string $string * @return string */ function show($string, $endOnly = true, $justSrc = false) { global $_PATH; // navigate path to Experiment folder (unless linking to external file) if (!inString('www.', $string)) { $fileName = $_PATH->get('Common') . '/' . $string; if (FileExists($fileName)) { $fileName = FileExists($fileName); } } else { $fileName = $string; } if ($endOnly) { $searchString = substr($fileName, -5); // only check last 5 characters for file extensions } else { $searchString = $fileName; } // check extension to determine which tags to add if (strripos($searchString, '.jpg') !== false || strripos($searchString, '.jpeg') !== false || strripos($searchString, '.png') !== false || strripos($searchString, '.gif') !== false || strripos($searchString, '.bmp') !== false) { // add image tags if ($justSrc) { $string = $fileName; } else { $string = '<img src="' . $fileName . '">'; } } elseif (strripos($searchString, '.mp3') || strripos($searchString, '.wav') || strripos($searchString, '.ogg')) { // audio tags if ($justSrc) { $string = $fileName; } else { $string = '<source src="' . $fileName . '"/>'; } } return $string; }