public function db()
 {
     //将MongoModel放入项目Lib\Model下并建一个测试的TestModel
     //将驱动放入核心的Lib\Driver\Db\下
     $mongo = D('Test');
     //显示表名
     $this->assign('table_name', $mongo->getTableName());
     //清除所有数据
     $map = array();
     $map['where'] = '1=1';
     $result = $mongo->delete($map);
     if ($result) {
         $this->assign('clear', 1);
     }
     //添加数据
     $data = array('title' => 'test', 'id' => '1');
     $mongo->add($data);
     $data['id'] = '2';
     $mongo->add($data);
     $add = $mongo->select();
     $this->assign('add', $add);
     //更新id为1的记录的title字段值设为title2
     $mongo->where(array('id' => '1'))->save(array('title' => 'title2'));
     $update = $mongo->select();
     $this->assign('update', $update);
     $action_code = highlight_file(__FILE__, 1);
     $this->assign('action_code', $action_code);
     $this->display();
 }
Exemple #2
0
 function tablesrc()
 {
     header('Content-type: text/html;charset=utf8');
     $file = APP_DIR . '/' . $_GET['tableapp'] . '/dbschema/' . $_GET['tablename'] . '.php';
     echo '<div style="padding:2px 10px;border-bottom:1px solid #ccc">' . $file . '</div>';
     highlight_file($file);
 }
Exemple #3
0
 /**
  * Preview code from a PHP file
  *
  * @param string   $file       file path
  * @param int|null $activeLine active line number
  * @param int|null $lineRange  range of lines to render (around active line)
  * @param string   $className  wrapper class name
  * @return string|null
  */
 public static function file($file, $activeLine = null, $lineRange = null, $className = 'code-preview')
 {
     $highlighted = @highlight_file($file, true);
     if (false !== $highlighted) {
         return self::render($highlighted, $activeLine, $lineRange, $className);
     }
 }
 /**
  * Index
  *
  * @return void
  */
 public function indexAction()
 {
     $this->view->navSetup = highlight_file('App/Demo/Navigation.setup.php', true);
     $this->view->navSetup = str_replace('Zym_Navigation_Demo',
                                         'Zym_Navigation',
                                         $this->view->navSetup);
 }
Exemple #5
0
 public function indexAction()
 {
     //如果邮件不能正常发送,请根据错误提示寻找原因
     //常见的问题就是没有开启IMAP/SMTP服务
     $time = microtime(1);
     $host = 'smtp.qq.com';
     $pors = 25;
     $user = '******';
     $pass = '******';
     $smtp = new emailModel($host, $pors, $user, $pass);
     $to = '接收邮箱';
     $from = $user;
     $subject = 'PHP邮件测试' . $time;
     //邮件主题
     $body = '测试成功';
     //邮件内容
     //定义如下两项后,发件人内容显示类似:PHP邮件测试<QQ邮箱>
     $from_email = $user;
     $from_name = 'PHP邮件测试';
     if ($smtp->send($to, $from, $subject, $body, $from_email, $from_name)) {
         echo '总耗时:', microtime(1) - $time;
     }
     echo '<h1>控制器源代码:</h1><hr />';
     highlight_file(__FILE__);
 }
 public function indexAction()
 {
     //调试状态关闭缓存功能,默认为调试状态。0:非调试状态 1:调试状态
     //在初始化mPHP前,可以通过配置$GLOBALS['CFG']['debug']来设定
     //初始化mPHP后,可以通过配置mPHP::$debug来设定
     mPHP::$debug = 0;
     //初始化阶段mPHP已经声明了视图类
     //mPHP::$view = new view();
     $view = mPHP::$view;
     $tpl = 'view';
     //模版名称
     $file = CACHE_PATH . "html/{$tpl}.html";
     //缓存html文件保存位置
     $time = 5;
     //缓存时间(秒)
     $cache = $view->cache($file, $time);
     if ($cache) {
         return true;
     }
     //缓存有效期内直接返回
     sleep(1);
     //模拟耗时操作
     $view->data['title'] = 'mPHP视图类缓存demo ';
     $view->data['h'] = 'hello ';
     $view->data['w'] = 'world ';
     $view->loadTpl($tpl);
     //加载模版
     highlight_file(__FILE__);
 }
/**
 * SmartTemplate Extension config
 * Print Content of Configuration Parameters
 *
 * Usage Example:
 * Content:  $_CONFIG['webmaster']  =  '*****@*****.**';
 * Template: Please Contact Webmaster: {config:"webmaster"}
 * Result:   Please Contact Webmaster: philipp@criegern.com
 *
 * @author Philipp v. Criegern philipp@criegern.com
 */
function stedisplayFileInHTML($directory, $file)
{
    if (file_exists($directory . "/" . $file)) {
        return highlight_file($directory . "/" . $file, 1);
    } else {
        return "File does not exist {$directory}, {$file}";
    }
}
Exemple #8
0
function showSource($dir, $file)
{
    $path = $dir . $file;
    echo '<div>';
    echo '<h1>' . $path . '</h1>';
    highlight_file($path);
    echo '</div>' . "\n";
}
 public function handle()
 {
     $types = array("php" => "text/html", "html" => "text/html", "htm" => "text/html", "css" => "text/css", "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "phps" => "text/html", "pdf" => "application/pdf", "" => "text/plain");
     $real_file = $this->options["rewrite"] ? $this->applyRewriteRules() : $this->request->path . "/" . $this->request->file;
     $extension = array_pop(explode(".", basename($real_file)));
     if (!in_array($extension, array_keys($types))) {
         $extension = "";
     }
     if (file_exists($this->request->document_root . $real_file)) {
         // DefaultHandler: File exists
         if ($extension == "phps") {
             $output = highlight_file($this->request->document_root . $real_file, true);
             $headers = array("Content-Type" => $types[$extension], "Content-Length" => strlen($output));
             $response = new Zend_Http_Response(200, $headers, $output);
         } else {
             if ($extension == "php") {
                 // DefaultHandler: PHP script
                 $current_directory = getcwd();
                 chdir(dirname($this->request->document_root . $real_file));
                 // Setting up globals
                 $_GET = $this->request->get;
                 $_POST = $this->request->post;
                 $_REQUEST = array_merge($_GET, $_POST);
                 $_SERVER["DOCUMENT_ROOT"] = $this->request->document_root;
                 $_SERVER["SCRIPT_FILENAME"] = $this->request->file;
                 $_SERVER["PHP_SELF"] = $this->request->path;
                 $_SERVER["SCRIPT_NAME"] = $this->request->path . "/" . $this->request->file;
                 $_SERVER["argv"] = $this->request->query_string;
                 $_SERVER["SERVER_ADDR"] = "";
                 $_SERVER["SERVER_NAME"] = "";
                 $_SERVER["SERVER_SOFTWARE"] = "Zend HTTP Server (alpha)";
                 $_SERVER["SERVER_PROTOCOL"] = "";
                 $_SERVER["REQUEST_METHOD"] = $this->request->method;
                 $_SERVER["REQUEST_TIME"] = time();
                 $_SERVER["QUERY_STRING"] = $this->request->query_string;
                 $_SERVER["REQUEST_URI"] = $this->request->uri;
                 $_SERVER["HTTP_HOST"] = $this->request->headers["Host"];
                 unset($_SERVER["argc"]);
                 $output = self::startScript($this->request->document_root . $real_file);
                 // DefaultHandler: Done.  Sending response.
                 chdir($current_directory);
                 $headers = array("Content-Type" => "text/html", "Content-Length" => strlen($output));
                 foreach (headers_list() as $header) {
                     list($name, $value) = split(":", $header);
                     $headers[$name] = $value;
                 }
                 $response = new Zend_Http_Response(200, $headers, $output);
             } else {
                 $data = file_get_contents($this->request->document_root . $real_file);
                 $response = new Zend_Http_Response(200, array("Content-Type" => $types[$extension], "Content-Length" => strlen($data)), $data);
             }
         }
     } else {
         $response = new Zend_Http_Response(404, array("Content-Type" => "text/plain"), "File Not Found!");
     }
     return $response;
 }
 /**
  * Highlighter with built-in check for list of disabled function (Google AppEngine)
  *
  * @param string $file Name of the file
  */
 public static function highlight($file)
 {
     $highlightFileFunc = new \ReflectionFunction('highlight_file');
     if (!$highlightFileFunc->isDisabled()) {
         highlight_file($file);
     } else {
         echo '<pre>' . htmlspecialchars(file_get_contents($file)) . '</pre>';
     }
 }
Exemple #11
0
 /**
  * Output a dump of a file
  *
  * @param mixed $file file to dump
  * @param bool  $echo true to echo dump, false to return dump as string
  *
  * @return string
  */
 public static function dumpFile($file, $echo = true)
 {
     $msg = highlight_file($file, true);
     $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>";
     if ($echo) {
         echo $msg;
     }
     return $msg;
 }
Exemple #12
0
 /**
  * Displays PHP code from selected file with syntax highlighting.
  * 
  * @param string filename
  */
 public function body($arg)
 {
     print '<div align="left">';
     if (file_exists($arg)) {
         highlight_file($arg);
     } else {
         echo "File {$arg} does not exist.";
     }
     print '</div>';
 }
Exemple #13
0
 public function onView($param)
 {
     $class = $param['source'];
     $file = "App/Control/{$class}.php";
     if (file_exists($file)) {
         $panel = new Panel('Código-fonte: ' . $class);
         $panel->add(highlight_file($file, TRUE));
         parent::add($panel);
     }
 }
Exemple #14
0
 protected function tnvExample_Change($strFormId, $strControlId, $strParameter)
 {
     $objItem = $this->tnvExample->SelectedItem;
     if (is_dir($this->tnvExample->SelectedValue)) {
         $this->pnlCode->Text = 'Current directory is <b>' . $this->tnvExample->SelectedItem->Name . '</b>.  ' . 'Please select a file on the left';
     } else {
         $strCode = highlight_file($this->tnvExample->SelectedValue, true);
         $this->pnlCode->Text = $strCode;
     }
 }
Exemple #15
0
 public static function ViewSource()
 {
     echo '<h1>You are looking at the output from MyClass::ViewSource</h1>
       <ul>
         <li><a href="/simple-site">Call MyClass::MyMethod</a></li>
         <li><a href="/simple-site/sample">Call MyClass::MyOtherMethod</a></li>
         <li><a href="/simple-site/somepath/source">View the source of this page</a></li>
       </ul>';
     highlight_file(__FILE__);
 }
Exemple #16
0
 function view_help()
 {
     global $tpl;
     $test_file = APP_DIR . "/client/test.php";
     $code = '';
     if (file_exists($test_file)) {
         $code = highlight_file($test_file, true);
     }
     $tpl->assign('code', $code);
 }
 public function viewSource()
 {
     if (!is_readable($this->source)) {
         return "<h1>File {$this->source} not found.</h1>";
     }
     ob_start();
     highlight_file($this->source);
     $output = ob_get_clean();
     return $output;
 }
Exemple #18
0
 public static function showException($e)
 {
     //Oraculum::Load('Logs');
     $filecode = NULL;
     $message = $e->getMessage();
     $code = $e->getCode();
     $file = $e->getFile();
     $line = $e->getLine();
     $trace = $e->getTrace();
     $traceasstring = $e->getTraceAsString();
     $report = '<h1>' . $message . '</h1>';
     $report .= '<strong>Error Code:</strong> #' . $code . '<br />';
     $report .= '<strong>Source File:</strong> ' . $file . ' <strong>line ' . $line . '</strong><br />';
     $report .= '<h3>Backtrace</h3>';
     foreach ($trace as $error) {
         if (isset($error['file'])) {
             $filecode = $error['file'];
             $report .= '<hr />';
             $report .= '<strong>File:</strong> ' . $filecode . ' <strong>line ' . $error['line'] . '</strong><br />';
         } else {
             $filecode = NULL;
         }
         $args = array();
         if ($error['args']) {
             foreach ($error['args'] as $arg) {
                 if (is_object($arg)) {
                     $args[] = get_class($arg) . ' object';
                 } elseif (is_array($arg)) {
                     $args[] = implode(',', $arg);
                 } else {
                     $args[] = (string) $arg;
                 }
             }
         }
         if (isset($error['class'])) {
             $report .= '<span style="color:#0a0;">' . $error['class'] . '</span>';
         }
         if (isset($error['type'])) {
             $report .= '<font style="color:#000;">' . $error['type'] . '</font>';
         }
         $report .= '<strong style="color:#00a;">' . $error['function'] . '</strong>';
         $report .= '(<font style="color:#a00;">\'' . implode(', ', $args) . '\'</font>);';
         if (!is_null($filecode)) {
             if (file_exists($filecode)) {
                 $cod = 'sourcecodedebug' . time() . rand();
                 $report .= '<br /><a href="#alert"' . $cod . '" onclick="document.getElementById(\'' . $cod . '\').style.display=\'block\';" style="color:#00a;">';
                 $report .= 'Show Source Code</a>';
                 $report .= '<div id="' . $cod . '" style="display:none;border:1px solid #444;background-color:#fff; word-wrap:break-word;">' . highlight_file($filecode, true) . '</div><br />';
             }
         }
     }
     $report = '<div style=\'float:left;text-align:left;\'>' . $report . '</div>';
     //echo $report;
     Logs::alert($report);
 }
Exemple #19
0
 public function generateInner()
 {
     if ($this->isSource) {
         $content = highlight_file($this->path, true);
         $t[] = new MDiv('', $this->path, '');
         $t[] = new MDiv('', $content, 'mFileContent');
         $this->inner = $t;
     } else {
         parent::generateInner();
     }
 }
 public function infoAction()
 {
     $className = $this->_getParam('class');
     $migration = new $className();
     $this->view->class_name = $className;
     $reflector = new ReflectionClass($className);
     $file = $reflector->getFileName();
     $this->view->file = $file;
     $this->view->source = highlight_file($file, true);
     $this->view->comment = $migration->getComment();
 }
 private function excerpt($file, $line)
 {
     if (is_readable($file)) {
         $content = preg_split('#<br />#', preg_replace('/^<code>(.*)<\\/code>$/s', '$1', highlight_file($file, true)));
         $lines = array();
         for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
             $lines[] = '<li' . ($i == $line ? ' class="selected"' : '') . '>' . $content[$i - 1] . '</li>';
         }
         return '<ol class="excerpt" start="' . max($line - 3, 1) . '">' . implode("\n", $lines) . '</ol>';
     }
 }
 /**
  * Returns an excerpt of a code file around the given line number.
  *
  * @param string $file  A file path
  * @param int    $line  The selected line number
  *
  * @return string An HTML string
  */
 protected function fileExcerpt($file, $line)
 {
     if (is_readable($file)) {
         $content = preg_split('#<br />#', highlight_file($file, true));
         $lines = array();
         for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; $i++) {
             $lines[] = '<li' . ($i == $line ? ' class="selected"' : '') . '>' . $content[$i - 1] . '</li>';
         }
         return '<ol start="' . max($line - 3, 1) . '">' . implode("\n", $lines) . '</ol>';
     }
 }
Exemple #23
0
function presentaCodiFont($codiFont)
{
    if (!file_exists($codiFont)) {
        return -1;
    }
    echo "<B>{$codiFont}<HR><FONT size = 3>";
    highlight_file($codiFont);
    echo "</font></B><P>";
    echo "<A href=\"{$codiFont}\">Executa-ho</a><HR>";
    return 0;
}
Exemple #24
0
 /**
  * Get lines from file
  *
  * @return array
  */
 protected function getLines()
 {
     if (!$this->lines) {
         $content = highlight_file($this->file, true);
         $content = $this->convertWhitespaces($content);
         $content = $this->removeBullshitMarkup($content);
         $content = $this->convertStyles($content);
         $this->lines = $this->splitLines($content);
     }
     return $this->lines;
 }
Exemple #25
0
 public function indexAction()
 {
     $arrDb = array('type' => 'mysql', 'dbname' => 'test', 'host' => 'localhost', 'port' => '3306', 'user' => 'root', 'password' => '', 'charset' => 'utf8');
     $pdo = new pdoModel($arrDb);
     $strSql = "show tables";
     $pdo->query($strSql);
     $arrData = $pdo->fetch_all();
     //效果一样 $arrData = $pdo->query($strSql)->fetch_all();
     print_r($arrData);
     echo '<h1>控制器源代码:</h1><hr />';
     highlight_file(__FILE__);
 }
Exemple #26
0
function tabs(array $files)
{
$tabshead = <<<HEAD1
<div id="tabs"  style="font-size:11px">
    <ul>
        <li><a href="#DescriptionContent"><span>Info</span></a></li>
        <li><a href="#HTMLContent"><span>HTML</span></a></li>
        <li><a href="#PHPCode"><span>PHP</span></a></li>
    </ul>
    <div id="DescriptionContent" style="font-size:1.1em !important">
HEAD1;
echo $tabshead;
// info file
$filename = "info.txt";
$lines = file($filename);

// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
    echo $line . "<br />\n";
}
// html content
echo "</div>";
echo '<div id="HTMLContent" style="font-size:1.1em !important">';
$filename = "default.php";
highlight_file($filename);
echo "</div>";
// php code
echo '<div id="PHPCode" style= "font-size:1em !important">';
for($i=0;$i<count($files);$i++)
{
    $filename = $files[$i];
    echo '<span style="font-size:1.2em !important">';
    echo "<b>".$filename."</b>.<br />\n";
    if(strlen($filename)>0)
    {
        highlight_file($filename);
    }
    echo "<span>";
}
echo "</div>"; // php code
echo "</div>"; // tabs
echo '<script type="text/javascript">';
echo '$("#tabs").tabs();';
echo '</script>';
$google = <<<GOOGLE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try { var pageTracker = _gat._getTracker("UA-5463047-4"); pageTracker._trackPageview(); } catch(err) {}
</script>
GOOGLE;
echo $google;
}
Exemple #27
0
 /**
  * Output a dump of a file
  *
  * @param mixed $file file which will be dumped
  * @param bool  $echo
  * @param bool  $exit
  *
  * @return string
  */
 static function dumpFile($file, $echo = true, $exit = false)
 {
     $msg = highlight_file($file, true);
     $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>";
     if (!$echo) {
         return $msg;
     }
     echo $msg;
     if ($exit) {
         die;
     }
     return $msg;
 }
function reset_flag()
{
    $new_flag = substr(md5(rand(10000000, 99999999) . "qwer" . rand(10000000, 99999999) . "asdf" . rand(10000000, 99999999)), 8, 16);
    $chk = @mysql_fetch_array(mysql_query("select id from prob_umaru where id='{$_SESSION[los_id]}'"));
    if (!$chk[id]) {
        mysql_query("insert into prob_umaru values('{$_SESSION[los_id]}','{$new_flag}')");
    } else {
        mysql_query("update prob_umaru set flag='{$new_flag}' where id='{$_SESSION[los_id]}'");
    }
    echo "reset ok";
    highlight_file(__FILE__);
    exit;
}
 private static function generateCodeBlock($errorLine, $filePath)
 {
     $lines = explode('<br />', highlight_file($filePath, true));
     $errorID = '';
     for ($n = 0; $n < count($lines); $n++) {
         $lineNumber = $n + 1;
         $paddedNumber = self::addPadding($lineNumber);
         $errorClass = '';
         list($errorClass, $errorID) = $lineNumber == $errorLine ? array('errorLine', md5($errorLine . $filePath)) : array('', $errorID);
         $lines[$n] = "<span class=\"lineNumbers {$errorClass}\" id=\"{$errorID}\">{$paddedNumber}</span>" . $lines[$n];
     }
     return "<div class=\"codeFile\" errorid=\"{$errorID}\">" . implode("<br />\n", $lines) . '</div>';
 }
Exemple #30
0
 public static function init()
 {
     if (array_key_exists('tracefile', $_GET)) {
         exit(highlight_file($_GET['tracefile'], true));
     }
     if (array_key_exists('mirror', $_GET)) {
         exit(self::getCacheFile($_GET['mirror']));
     }
     self::instance()->classes = get_declared_classes();
     self::instance()->functions = get_defined_functions();
     error_reporting(E_ALL | E_STRICT);
     function_exists('xdebug_start_code_coverage') && xdebug_start_code_coverage();
     self::add('Environment', array('_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, '_SERVER' => $_SERVER));
 }