本文整理汇总了PHP中FileSystem::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::getFile方法的具体用法?PHP FileSystem::getFile怎么用?PHP FileSystem::getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::getFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJson
public static function getJson($code, $path = '/', $type = 'arr')
{
import('ORG.Net.FileSystem');
$sys = new FileSystem();
//main
$basepath = RUNTIME_PATH . 'Data/Json/' . $path;
$filename = '/' . $code . '_data.json';
$json = $sys->getFile($basepath . $filename);
if ($type == 'obj') {
return json_decode($json);
} elseif ($type == 'arr') {
return json_decode($json, true);
}
}
示例2: show
/**
* 显示备份、还原数据库流
*@param $act bak为备份、re为还原
*@param $total 传入表总数
*@param $go 为1时,获取post
*@examlpe
*/
public function show($act, $total = NULL, $go = -1, $page = -1)
{
$Public = A('Index', 'Public');
$Public->check('Backup', array('c'));
$sql = A('Sql', 'Public');
//实例化sql类
//实例化文件系统操作类
import('ORG.Net.FileSystem');
$path = new FileSystem();
$path->root = ITEM;
$path->charset = C('CFG_CHARSET');
set_time_limit(1000);
//main
if ($go >= 0) {
if ($act == 'bak') {
$str_table = $path->getFile(RUNTIME_PATH . '/database.tmp');
$arr_table = unserialize($str_table);
if ($go == count($arr_table['table'])) {
cookie('badate', NULL);
$path->delFile(RUNTIME_PATH . '/database.tmp');
$path->delFile(RUNTIME_PATH . '/backup.tmp');
cookie('info_step', NULL);
cookie('info_page', NULL);
echo '所有表已完成备份!|0|0';
exit;
}
if (cookie('badate')) {
$badate = cookie('badate');
} else {
$badate = date("Y-m-d_His");
cookie('badate', $badate);
}
$bak_dir = ROOT . '/Conf/Backup/' . $badate;
if (!file_exists($bak_dir)) {
$path->putDir($bak_dir, 0777);
}
$strfile = '';
$table = $arr_table['table'][$go];
$tb = str_replace(C('DB_PREFIX'), '#@_', $table);
$result = M();
$str_info = $path->getFile(RUNTIME_PATH . '/backup.tmp');
if ($str_info) {
$str_info = slashes($str_info);
$info = unserialize($str_info);
$page = cookie('info_page') ? cookie('info_page') : 0;
$p = cookie('info_step') ? cookie('info_step') : 1;
} else {
$count = $result->table($table)->count();
$total = ceil($count / 10000);
if (cookie('info_page')) {
$page = cookie('info_page');
} else {
$page = 0;
}
if ($count > 10000) {
$info = $result->table($table)->limit($page * 10000, 10000)->select();
if ($page < $total) {
if ($page == 0) {
$p = 1;
} else {
$p = cookie('info_step') ? cookie('info_step') : 1;
}
$page++;
cookie('info_page', $page);
if ($p == 1) {
$strfile .= "DROP TABLE IF EXISTS `" . $tb . "`;\r\n";
$table_field = $sql->getField($table);
//获取表结构
//替换数据表名
$mysql = mysql_get_server_info();
$get_field = preg_replace("/AUTO_INCREMENT=[0-9]+\\s+/", "", $table_field);
if ($arr_table['version'] == 4.1 && $mysql > 4.1) {
$get_field = preg_replace("/ENGINE=\\b.{2,}\\b DEFAULT CHARSET=\\S+/", 'ENGINE=MyISAM DEFAULT CHARSET=' . $arr_table['charset'], $get_field);
} elseif ($arr_table['version'] == 4.1 && $mysql < 4.1) {
$get_field = preg_replace("TYPE=\\b.{2,}\\b", 'ENGINE=MyISAM DEFAULT CHARSET=' . $arr_table['charset'], $get_field);
} elseif ($arr_table['version'] == 4.0 && $mysql > 4.1) {
$get_field = preg_replace("/ENGINE=\\b.{2,}\\b DEFAULT CHARSET=\\S+/", 'TYPE=MyISAM', $get_field);
}
$strfile .= str_replace('CREATE TABLE `' . C('DB_PREFIX'), 'CREATE TABLE `#@_', $get_field . ";\r\n");
}
} else {
$page = 0;
cookie('info_page', NULL);
$p = cookie('info_step') ? cookie('info_step') : 1;
}
} else {
$strfile .= "DROP TABLE IF EXISTS `" . $tb . "`;\r\n";
$table_field = $sql->getField($table);
//获取表结构
//替换数据表名
$mysql = mysql_get_server_info();
$get_field = preg_replace("/AUTO_INCREMENT=[0-9]+\\s+/", "", $table_field);
if ($arr_table['version'] == 4.1 && $mysql > 4.1) {
//.........这里部分代码省略.........
示例3: upver
/**
* 升级检查
*@examlpe
*/
public function upver()
{
$nowtime = time();
import('ORG.Net.FileSystem');
$sys = new FileSystem();
$sys->root = ITEM;
$sys->charset = C('CFG_CHARSET');
$App = A('App', 'Public');
//main
$nowdate = date("Y-m-d H:i:s", $nowtime);
$path = CONF_PATH . 'version.txt';
$ver = $sys->getFile($path);
$arr_ver = explode(";\r\n", $ver);
$arr_ver = array_filter($arr_ver);
$content = $arr_ver[0] . ";\r\n" . $nowdate . ";\r\n" . $arr_ver[2] . ";\r\n";
$sys->putFile($path, $content);
echo "当前版本:{$arr_ver['0']} 最后检测时间:{$nowdate}";
}
示例4: role
/**
* 编辑权限配置文件
*@param $id 传入的数据ID
*@examlpe
*/
public function role($id, $go = 0)
{
import('ORG.Net.FileSystem');
$sys = new FileSystem();
$Public = A('Index', 'Public');
//main
$id = intval($id);
if ($go == 0) {
$menu = M('Menu');
$code = $menu->where('id=' . $id)->getField('code');
$path = CONF_PATH . '/Role/' . $code . 'Role.php';
$file = $sys->getFile($path);
$this->assign('file', $file);
$this->assign('code', $code);
$this->assign('uniqid', uniqid());
$this->assign('id', $id);
$this->assign('path', '/Conf/Role/' . $code . 'Role.php');
$this->display();
} else {
$role = $Public->check('Menu', array('u'));
if ($role < 0) {
echo $role;
exit;
}
$code = I('code');
$data = I('file', '', false);
if (!preg_match("/^\\<\\?php/i", $data)) {
$data = "<?php\r\n" . $data;
}
$path = $path = CONF_PATH . '/Role/' . $code . 'Role.php';
if ($code) {
$edit = $sys->putFile($path, $data);
if ($edit == 1) {
echo 1;
} else {
echo 0;
}
} else {
echo 2;
}
}
}