/** * 渲染验证码图像。 */ protected function renderImage() { if (!isset($this->imageOptions['id'])) { $this->imageOptions['id'] = $this->getId(); } $url = $this->getController()->createUrl($this->captchaAction, array('v' => uniqid())); $alt = isset($this->imageOptions['alt']) ? $this->imageOptions['alt'] : ''; echo Html::image($url, $alt, $this->imageOptions); }
<title>请求错误</title> <style type="text/css"> /*<![CDATA[*/ body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;} h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } h3 {font-family:"Verdana";font-weight:bold;font-size:11pt} p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px} .version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;} /*]]>*/ </style> </head> <body> <h1>请求错误</h1> <h2><?php echo nl2br(\Sky\help\Html::encode($data['message'])); ?> </h2> <p> 由于语法错误,服务器无法解析. 请修改请求后重试. </p> <p> 如果您认为此错误是服务器造成的,请与管理员联系 <?php echo $data['admin']; ?> . </p> <div class="version"> <?php echo date('Y-m-d H:i:s', $data['time']) . ' ' . $data['version'];
public static function getInstance($model, $attribute) { return self::getInstanceByName(Html::resolveName($model, $attribute)); }
/** * 显示错误行周围的代码 * @param string $file 源文件路径 * @param integer $errorLine 错误行号 * @param integer $maxLines 最大显示的行数 * @return string 显示的结果 */ protected function renderSourceCode($file, $errorLine, $maxLines) { $errorLine--; // adjust line number to 0-based from 1-based if ($errorLine < 0 || ($lines = @file($file)) === false || ($lineCount = count($lines)) <= $errorLine) { return ''; } $halfLines = (int) ($maxLines / 2); $beginLine = $errorLine - $halfLines > 0 ? $errorLine - $halfLines : 0; $endLine = $errorLine + $halfLines < $lineCount ? $errorLine + $halfLines : $lineCount - 1; $lineNumberWidth = strlen($endLine + 1); $output = ''; for ($i = $beginLine; $i <= $endLine; ++$i) { $isErrorLine = $i === $errorLine; $code = sprintf("<span class=\"ln" . ($isErrorLine ? ' error-ln' : '') . "\">%0{$lineNumberWidth}d</span> %s", $i + 1, \Sky\help\Html::encode(str_replace("\t", ' ', $lines[$i]))); if (!$isErrorLine) { $output .= $code; } else { $output .= '<span class="error">' . $code . '</span>'; } } return '<div class="code"><pre>' . $output . '</pre></div>'; }
public function fileField($model, $attribute, $htmlOptions = array()) { return Html::activeFileField($model, $attribute, $htmlOptions); }
<th style="background:black;color:white;" colspan="5"> 应用日志 </th> </tr> <tr style="background-color: #ccc;"> <th style="width:120px">时间戳</th> <th>级别</th> <th>分类</th> <th>消息</th> </tr> <?php $colors = array(\Sky\logging\Logger::LEVEL_INFO => '#FFFFDF', \Sky\logging\Logger::LEVEL_WARNING => '#FFDFE5', \Sky\logging\Logger::LEVEL_ERROR => '#FFC0CB'); foreach ($data as $index => $log) { $color = $index % 2 ? '#F5F5F5' : '#FFFFFF'; if (isset($colors[$log[1]])) { $color = $colors[$log[1]]; } $message = '<pre>' . \Sky\help\Html::encode(wordwrap($log[0])) . '</pre>'; $time = date('H:i:s.', $log[3]) . sprintf('%06d', (int) (($log[3] - (int) $log[3]) * 1000000)); echo <<<EOD \t<tr style="background:{$color}"> \t\t<td align="center">{$time}</td> \t\t<td>{$log[1]}</td> \t\t<td>{$log[2]}</td> \t\t<td>{$message}</td> \t</tr> EOD; } ?> </table> <!-- end of log messages -->