static function create($type, $options, $cachedDir) { //echo "$type---\n"; switch ($type) { case "geshi": $provider = Geshi::getInstance(); break; case "highlight": $provider = Highlight::getInstance(); break; case "pygment": $provider = Pygment::getInstance(); break; case "httpappspot": $provider = HttpAppspot::getInstance(); break; case "httphiliteme": $provider = HttpHiliteme::getInstance(); break; default: throw new \Exception("Highlighter < {$type} > not implemented"); } $opt = array(); $options[$type]['cssclass'] .= " " . $options['globals']['cssclass']; foreach ($options[$type] as $k => $v) { if ($v !== null and $v !== "") { $opt[$k] = $v; } } $opt = array_merge(array_diff($options['globals'], $opt), $opt); $provider->setOptions($opt); $provider->setCachedDir($cachedDir); return $provider; }
static function select() { $conn = Database::connect(); $sth = mysqli_query($conn, "SELECT * FROM `linkpreview`.`linkpreview` ORDER BY id DESC"); $rows = array(); while ($r = mysqli_fetch_assoc($sth)) { $r["text"] = Highlight::url($r["text"]); $r["description"] = Highlight::url($r["description"]); $rows[] = $r; } return $rows; }
<?php include_once "highlight.class.php"; $hl = new Highlight(); $args = explode("/", $_GET["arg"]); if ($args[0] == "botadd") { $hl->coeBotHighlight($args[1], $args[2]); } else { if ($args[0] == "add") { if ($args[1] == "direct") { die("rip in pepperinos"); //$hl->directHighlightThat($args[2]); } else { if ($args[1] == "coebot") { $hl->coeBotHighlight($args[2], $args[3]); } else { die("rip in pepperinos"); //$hl->highlightThat($args[1]); } } } else { if ($args[0] == "view") { die("rip in pepperinos"); $hl->viewHighlights($args[1], $args[2]); } else { if ($args[0] == "api") { if ($args[1] == "hl") { $hl->jsonifyHighlights($args[2], $args[3]); } else { if ($args[1] == "stats") { if ($args[3]) {
<?php /** * Copyright (c) 2015 Leonardo Cardoso (http://leocardz.com) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * Version: 1.0.0 */ /** * This file is only to hightlight the urls that are found shown when post is already posted. :) * So, it has nothing bound directly to LinkPreview class */ include_once "classes/SetUp.php"; include_once "classes/Highlight.php"; SetUp::init(); $data = json_decode(urldecode(base64_decode($_POST["data"]))); $text = $data->text; $description = $data->description; $answer = array("text" => Highlight::url($text), "description" => Highlight::url($description)); echo json_encode($answer);
/** * Displays a message in the text console. * * @param Exception $exception */ public static function showConsoleException($exception) { $isXTermColor = false; if (isset($_ENV['TERM'])) { foreach (array('256color') as $term) { if (preg_match('/' . $term . '/', $_ENV['TERM'])) { $isXTermColor = true; } } } $isSupportedShell = false; if ($isXTermColor) { if (isset($_ENV['SHELL'])) { foreach (array('bash', 'tcl') as $shell) { if (preg_match('/' . $shell . '/', $_ENV['SHELL'])) { $isSupportedShell = true; } } } } ScriptColor::setFlags($isSupportedShell && $isSupportedShell); $output = ""; $output .= ScriptColor::colorize(get_class($exception) . ': ', ScriptColor::RED, ScriptColor::BOLD); $message = str_replace("\"", "\\\"", $exception->getMessage()); $message .= ' (' . $exception->getCode() . ')'; $output .= ScriptColor::colorize($message, ScriptColor::WHITE, ScriptColor::BOLD); $output .= '\\n'; $output .= Highlight::getString(file_get_contents($exception->getFile()), 'console', array('firstLine' => $exception->getLine() - 3 < 0 ? $exception->getLine() : $exception->getLine() - 3, 'lastLine' => $exception->getLine() + 3)); $i = 1; $getcwd = getcwd(); foreach ($exception->getTrace() as $trace) { $output .= ScriptColor::colorize('#' . $i, ScriptColor::WHITE, ScriptColor::UNDERLINE); $output .= ' '; if (isset($trace['file'])) { $file = str_replace($getcwd, '', $trace['file']); $output .= ScriptColor::colorize($file . '\\n', ScriptColor::NORMAL); } $i++; } if ($isSupportedShell) { system('echo -e "' . $output . '"'); } else { echo $output; } }