/** * 获取缓存,按需重载 * @param string $cachename * @return mixed */ protected function getCache($cachename) { $file = $cachename . ".json"; if (file_exists($file)) { return json_decode(File::read_file($cachename), true); } else { return []; } }
function PclZip_test() { $zip = new PclZip('data.zip'); $zip->create('sql-dfdata.txt'); if (!is_file('data.zip')) { return false; } $zip->extract(PCLZIP_OPT_PATH, './_data'); if (!is_file('./_data/sql-dfdata.txt')) { return false; } $content = File::read_file('./_data/sql-dfdata.txt'); if (empty($content)) { return false; } return true; }
private function parsefieldsetmode($tag, $mode, $display = false) { $tagvar = ''; if ($tag['group'] == $mode) { if ($tag['tag'] == 'input') { $tag['value'] = $display == true ? "<field name='{$tag['name']}' prefix='addonlist'/>" : $tag['value']; $tagvar = "<input type='{$tag['type']}' group='{$mode}' name='{$tag['name']}' id='{$tag['id']}' size='{$tag['size']}' style='{$tag['style']}' value='{$tag['value']}' {$tag['extend']}/>"; } elseif ($tag['tag'] == 'inserturl') { $tag['value'] = $display == true ? "<field name='{$tag['name']}' prefix='addonlist'/>" : $tag['value']; $tagvar = "<input type='{$tag['type']}' group='{$mode}' name='{$tag['name']}' id='{$tag['id']}' size='{$tag['size']}' style='{$tag['style']}' value='{$tag['value']}' {$tag['extend']}/>"; $tagvar .= <<<DATA \t\t\t\t<script> \t\t\t\tKindEditor.ready(function(K){ \t\t\t\tK('#{$tag['id']}').click(function() { \t\t\t\tif(K('#{$tag['id']}').val() ==''){url ='http://';}else{url=K('#{$tag['id']}').val();} \t\t\t\t\t\$.dialog.prompt('请输入网址', function (val) { \t\t\tif(val =='' || val=='http://'){K('#{$tag['id']}').val('http://');}else{K('#{$tag['id']}').val(val);} }, url);}); \t\t\t\t}); \t\t\t\t</script> DATA; } elseif ($tag['tag'] == 'insertfile') { $tag['value'] = $display == true ? "<field name='{$tag['name']}' prefix='addonlist'/>" : $tag['value']; $tagvar = "<input type='{$tag['type']}' group='{$mode}' name='{$tag['name']}' id='{$tag['id']}' size='{$tag['size']}' style='{$tag['style']}' value='{$tag['value']}' {$tag['extend']}/>"; $tagvar .= <<<DATA \t\t\t\t<script> \t\t\t\tKindEditor.ready(function(K) { \t\t\t\tK('#{$tag['id']}').click(function() { \t\t\t\t\tvar editor = K.editor({ \t\t\t\t\tallowFileManager : false, \t\t\t\t\tkeepOriginName : false, \t\t\t\t\tuserAllowUpload:true, \t\t\t\t\tremoveTitle:true \t\t\t\t}); \t\t\t\t\teditor.loadPlugin('insertfile', function() { \t\t\t\t\t\teditor.plugin.fileDialog({ \t\t\t\t\t\t\tfileUrl : K('#{$tag['id']}').val(), \t\t\t\t\t\t\tclickFn : function(url, title) { \t\t\t\t\t\t\t\tK('#{$tag['id']}').val(url); \t\t\t\t\t\t\t\teditor.hideDialog(); \t\t\t\t\t\t\t} \t\t\t\t\t\t}); \t\t\t\t\t}); \t\t\t\t}); \t\t\t}); \t\t\t\t</script> DATA; } elseif ($tag['tag'] == 'insertpic') { $tag['value'] = $display == true ? "<field name='{$tag['name']}' prefix='addonlist'/>" : ''; $tagvar = "<input type='{$tag['type']}' group='{$mode}' name='{$tag['name']}' id='{$tag['id']}' size='{$tag['size']}' style='{$tag['style']}' value='{$tag['value']}' {$tag['extend']}/>"; $tagvar .= <<<DATA \t\t\t\t<script> \t\t\t\tKindEditor.ready(function(K) { \t\t\t\tK('#{$tag['id']}').click(function() { \t\t\t\t\tvar editor = K.editor({ \t\t\t\t\tallowFileManager : false, \t\t\t\t\tallowImageUpload : true, \t\t\t\t\tuserAllowUpload : true, \t\t\t\t\tremoveSize:true, \t\t\t\t\tremoveAlign:true, \t\t\t\t\tresizeWidth:true, \t\t\t\t\tresizeHeight:true, \t\t\t\t\tremoveTitle:true \t\t\t\t}); \t\t\t\t\teditor.loadPlugin('image', function() { \t\t\t\t\t\teditor.plugin.imageDialog({ \t\t\t\t\t\t\timageUrl : K('#{$tag['id']}').val(), \t\t\t\t\t\t\tclickFn : function(url, title, width, height, border, align) { \t\t\t\t\t\t\t\t\tK('#{$tag['id']}').val(url); \t\t\t\t\t\t\t\t\teditor.hideDialog(); \t\t\t\t\t\t\t} \t\t\t\t\t\t\t}); \t\t\t\t\t\t \t\t\t\t\t}); \t\t\t\t}); \t\t\t}); \t\t\t\t</script> DATA; } elseif ($tag['tag'] == 'checkbox') { $values = explode(",", $tag['value']); foreach ($values as $k => $v) { $value_set = $display == true ? "<field name='{$tag['name']}' prefix='addonlist' function=\"in_array('{$k}',explode(',',@me))?'checked':''\"/>" : ''; $tagvar .= $v . "<input name='{$tag['name']}-{$k}' group='{$mode}' type='checkbox' class='noborder' id='{$tag['name']}-{$k}' value='{$k}' style='{$tag['style']}' {$tag['extend']} {$value_set}/>"; } } elseif ($tag['tag'] == 'textarea') { $tag['value'] = $display == true ? "<field name='{$tag['name']}' prefix='addonlist'/>" : $tag['value']; $tagvar = "<textarea name='{$tag['name']}' group='{$mode}' id='{$tag['id']}' cols='60' rows='60' style='{$tag['style']}' {$tag['extend']} >{$tag['value']}</textarea>"; } elseif ($tag['tag'] == 'editor') { $tag['value'] = $display == true ? "<field name='{$tag['name']}' prefix='addonlist'/>" : $tag['value']; $tagvar .= "<script charset='utf-8' src='" . __ROOT__ . "/Public/Editor/kindeditor/editor.php?theme={$tag['theme']}&fm={$tag['fm']}&id={$tag['id']}'></script>"; $tagvar .= "<textarea name='{$tag['name']}' id='{$tag['id']}' group='{$mode}' cols='60' rows='60' style='{$tag['style']}' {$tag['extend']}>{$tag['value']}</textarea>"; } elseif ($tag['tag'] == 'radio') { $values = explode(",", $tag['value']); foreach ($values as $k => $v) { $value_set = $display == true ? "<field name='{$tag['name']}' prefix='addonlist' function=\"@me=='{$k}'?'checked':''\"/>" : ''; if (!$display && $k == 0) { $value_set = 'checked'; } $tagvar .= $v . "<input name='{$tag['name']}' group='{$mode}' type='radio' class='noborder' id='{$tag['name']}-{$k}' value='{$k}' style='{$tag['style']}' {$tag['extend']} {$value_set}/>"; } } elseif ($tag['tag'] == 'select') { $tagvar .= "<select name='{$tag['name']}' group='{$mode}' style='{$tag['style']}' {$tag['extend']}>"; $values = explode(",", $tag['value']); foreach ($values as $k => $v) { $value_set = $display == true ? "<field name='{$tag['name']}' prefix='addonlist' function=\"@me=='{$k}'?'selected=selected':''\"/>" : ''; $tagvar .= "<option value='{$k}'{$value_set}>{$v}</option>"; } $tagvar .= "</select>"; } if ($display && !empty($tag['editsrc'])) { $editcontent = substr($tag['editsrc'], 0, 1) == '.' ? File::read_file($tag['editsrc']) : fopen_url($tag['editsrc']); if ($tag['srcdisplayed'] == 1) { $editcontent = $this->fetch('', $editcontent . ' '); } $tagvar .= $editcontent; } if (!$display && !empty($tag['addsrc'])) { $content = substr($tag['addsrc'], 0, 1) == '.' ? File::read_file($tag['addsrc']) : fopen_url($tag['addsrc']); if ($tag['srcdisplayed'] == 1) { $content = $this->fetch('', $content . ' '); } $tagvar .= $content; } return $tagvar; } }
public function remoteinstall() { $url = $this->_get('url'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); //检测是否已经安装 $model = M('arcmodel'); $id = $model->order('id desc')->getField('id') + 1; if ($model->where("nid='" . $filename . "'")->find()) { $this->error('系统已安装当前模型!'); } //获取数据并解压缩 $tplpath = './Public/Model/' . $filename; File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); //删除压缩包 @unlink($filepath); //导入数据 $sqlfile = $tplpath . '/data.sql'; if (is_file($sqlfile)) { $sql = explode('###', strtr(File::read_file($sqlfile), array('#@__' => C('DB_PREFIX'), '__LINE__' => $id))); foreach ($sql as $v) { $model->execute(trim($v)); } } //刷新缓存 jump(U('Arcmodel/over')); }
<div class="panel-body row"> <div class="col-sm-12"> <p>Na página inicial do carômetro, deve haver um texto que visa explicar a utilidade do sistema, e como ele poderia ser construído. Aqui, você pode editar esse texto, de acordo com suas necessidades.</p> <div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"> Por favor, utilize títulos à partir do terceiro nível de cabeçalho.</span></div> <form role="form" action="action.php" method='post'> <textarea name="texto_inicial" id="texto_inicial" rows="10" cols="80"> <?php $texto = new File('texto.txt'); echo $texto->read_file(); ?> </textarea> <script> CKEDITOR.replace( 'texto_inicial' ); </script><br> <button type="submit" class="btn btn-default" name="form_button" value="texto-inicial">Enviar Texto</button> </form> </div> </div>
public function setdefault() { $name = $this->_get('name'); $demo = $this->_get('demo'); $backup = $this->_get('backup'); $plugin = $this->_get('plugin'); if (empty($name)) { $this->error('参数不正确!'); } $model = M('config'); $map['varname'] = 'cfg_wap_tpl_default'; $list = $model->field('id')->where($map)->find(); $map['id'] = $list['id']; $map['value'] = $name; $model->save($map); if ($demo == 1) { //检测演示数据安装 $demosqlpath = './Public/Wap/' . $name . '/demo.sql'; if (file_exists($demosqlpath)) { $rs = new Model(); $sql = File::read_file($demosqlpath); $sql = str_replace("\r\n", "\n", $sql); foreach (explode(";\n", trim($sql)) as $query) { $rs->query(trim($query)); } } } if ($backup == 1) { //数据备份 global $cfg_wap_tpl_default; $rs = new Model(); $list = $rs->query("SHOW TABLES FROM " . "`" . C('DB_NAME') . "`"); $filesize = 2048; $file = './Public/Backup/'; $random = mt_rand(1000, 9999); $sql = ''; $p = 1; foreach ($list as $k => $v) { $table = current($v); //仅备份当前系统的数据库表 $prefix = C('DB_PREFIX'); if (substr($table, 0, strlen($prefix)) == $prefix) { $rs = D(str_replace(C('DB_PREFIX'), '', $table)); $array = $rs->select(); $sql .= "TRUNCATE TABLE `{$table}`;\n"; foreach ($array as $value) { $sql .= $this->insertsql($table, $value); if (strlen($sql) >= $filesize * 1000) { $filename = $file . 'theme_' . $cfg_df_style . '_' . date('Ymd') . '_' . $random . '_' . $p . '.sql'; File::write_file($filename, $sql); $p++; $sql = ''; } } } } if (!empty($sql)) { $filename = $file . 'waptheme_' . $cfg_wap_tpl_default . '_' . date('Ymd') . '_' . $random . '_' . $p . '.sql'; File::write_file($filename, $sql); } } if ($plugin == 1) { //依赖插件安装 $prepluginpath = './Public/Wap/' . $name . '/plugin'; $list = File::get_dirs($prepluginpath); if (!empty($list['file'])) { import('ORG.PclZip'); foreach ($list['file'] as $v) { $filename = substr($v, 0, -4); $model = M('plugin'); if (!$model->where("title='" . $filename . "'")->find()) { //插件解压缩 $zip = new PclZip($prepluginpath . '/' . $v); $zip->extract(PCLZIP_OPT_PATH, './Public/Plugin/' . $filename); //安装插件 $data['description'] = ''; $data['author'] = ''; $data['copyright'] = ''; $xmlpath = './Public/Plugin/' . $filename . '/plugin.xml'; if (file_exists($xmlpath)) { $tag = simplexml_load_file($xmlpath); $data['author'] = (string) $tag->author; $data['copyright'] = (string) $tag->copyright; $data['description'] = (string) $tag->description; } $data['status'] = 0; $data['title'] = $filename; $data['pubdate'] = time(); $model->add($data); $path = './Public/Plugin/' . $filename . '/admin.php'; if (file_exists($path)) { set_include_path(__ROOT__); include $path; call_user_func(array($title . 'Plugin', '__install')); } } } } } $this->success('操作成功!', U('Wap/index')); }
public function edit() { //安全验证 $this->checksafeauth(); $nowdir = isset($_GET['dir']) ? urldecode($_GET['dir']) : ''; if (empty($nowdir)) { $this->error('参数不正确!'); } $file = '.' . $nowdir; $this->assign('filename', $file); if (!file_exists($file)) { $this->error('文件不存在!'); } import('ORG.String'); $this->assign("content", String::setCharset(File::read_file($file))); C('TMPL_PARSE_STRING.__ROOT__', '__ROOT__'); C('TMPL_PARSE_STRING.__APP__', '__APP__'); C('TMPL_PARSE_STRING.__PUBLIC__', '__PUBLIC__'); $this->display(); }
public function showover() { $date = isset($_GET['date']) ? $_GET['date'] : 0; $dir = './_update/' . $date; if (!is_dir($dir)) { $this->error('未检测到更新内容!'); } $content = File::read_file($dir . '/log.txt'); $this->assign('log', explode('###', $content)); $this->display(); }
/** * include标签解析 载入模板 * @access public * @param string $attr 标签属性 * @return string|void */ public function _include($attr) { global $cfg_df_style, $cfg_wap_tpl_default; $tag = $this->parseXmlAttr($attr, 'include'); $mode = isset($_GET['mode']) ? $_GET['mode'] : ''; $dir = $mode == 'wap' ? 'Wap' : 'Tpl'; $style = $mode == 'wap' ? $cfg_wap_tpl_default : $cfg_df_style; //跨目录支持 if (substr($tag['filename'], 0, 3) == '../') { $filename = str_replace('../', './Public/' . $dir . '/', $tag['filename']); } elseif (substr($tag['filename'], 0, 3) != '../' && substr($tag['filename'], 0, 2) == './') { $filename = $tag['filename']; } else { $filename = './Public/' . $dir . '/' . $style . '/' . $tag['filename']; } if (!file_exists($filename)) { return '模板文件:' . $filename . '不存在!'; } $parseStr = $this->tpl->parse(File::read_file($filename)); return $parseStr; }
public function back() { $rs = new Model(); $pre = $_GET['id']; $fileid = $_GET['fileid'] ? intval($_GET['fileid']) : 1; $filename = $pre . $fileid . '.sql'; $filepath = './Public/Backup/' . $filename; if (file_exists($filepath)) { $sql = File::read_file($filepath); $sql = str_replace("\r\n", "\n", $sql); foreach (explode(";\n", trim($sql)) as $query) { $rs->query(trim($query)); } $this->success('第' . $fileid . '个备份文件恢复成功,准备恢复下一个,请稍等!', U('Backup/back?id=' . $pre . '&fileid=' . ($fileid + 1))); } else { $this->success("数据库恢复成功!", U("Backup/index")); } }
</select> </div> </div> <div class="form-group" id="turma-form-group"> <label class="control-label col-sm-2" for="form-turma">Turma:</label> <div class="col-sm-10"> <select class="form-control" name="form-turma" id="form-turma" aria-required="true" required="true"> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="form-imagem">Imagem:</label> <div class="col-sm-10"> <input type="file" name="form-imagem" id="form-imagem" aria-required="true" required="true"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-lg btn-default" name="form-button">Enviar Imagem</button> </div> </div> </form> </div> <div class="col-sm-6" id="explicacao"> <?php $file = new File('texto.txt'); echo $file->read_file(); ?> </div> </div>
public function splitword() { header("charset=utf-8"); $str = trim($_POST['str']); if (empty($str)) { return; } $data = File::read_file('./Public/Data/keyword.txt'); $arr = explode("\r\n", $data); $a = ''; foreach ($arr as $v) { if (preg_match('/' . $v . '/', $str)) { $a .= $v . ','; } } echo trim($a, ','); exit; }