当前位置: 首页>>代码示例>>PHP>>正文


PHP FileSystem::putFile方法代码示例

本文整理汇总了PHP中FileSystem::putFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::putFile方法的具体用法?PHP FileSystem::putFile怎么用?PHP FileSystem::putFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem的用法示例。


在下文中一共展示了FileSystem::putFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write

 public function write($path, $data, $mode)
 {
     import('ORG.Net.FileSystem');
     $paths = new FileSystem();
     $paths->root = ITEM;
     $paths->charset = C('CFG_CHARSET');
     //main
     if ($mode == 'conf') {
         if (!is_writeable(ROOT . '/Conf')) {
             return -1;
         }
         $fp = fopen($path, 'wb');
         flock($fp, 3);
         fwrite($fp, "<" . "?php\r\n");
         fwrite($fp, "return array(\r\n");
         //dump($data);
         foreach ($data as $fval) {
             $fval['vals'] = htmlspecialchars_decode($fval['vals']);
             if ($fval['types'] == 'int' || $fval['types'] == 'bool') {
                 if ($fval['vals'] == "") {
                     $fval['vals'] = 0;
                 }
                 fwrite($fp, "\t'" . $fval['keyword'] . "' => " . addslashes($fval['vals']) . ",\r\n");
             } elseif ($fval['types'] == 'select' || $fval['types'] == 'more') {
                 list($key, $val) = explode('>>', $fval['vals']);
                 if ($key == 'none') {
                     fwrite($fp, "\t'" . $fval['keyword'] . "' => '',\r\n");
                 } else {
                     fwrite($fp, "\t'" . $fval['keyword'] . "' => '" . addslashes($key) . "',\r\n");
                 }
             } else {
                 fwrite($fp, "\t'" . $fval['keyword'] . "' => '" . addslashes($fval['vals']) . "',\r\n");
             }
         }
         fwrite($fp, ");");
         fclose($fp);
         return 1;
     } elseif ($mode && $mode != 'conf') {
         if (!file_exists($path)) {
             $paths->putDir($path);
         }
         if (!is_writeable($path)) {
             return -1;
         }
         $put = $paths->putFile($path . '/' . $mode . '.json', $data);
         return $put;
     } else {
         $this->error('未知操作模式,请检查!');
     }
 }
开发者ID:huangchuping,项目名称:bug,代码行数:50,代码来源:WritePublic.class.php

示例2: upload

 /**
  * move uploaded file to current directory
  *
  * @param string $src		source file path
  * @param string $newName	new file name
  * @return boolean
  */
 function upload($src, $newName)
 {
     if ($this->FileManager->hideSystemFiles && $newName[0] == '.') {
         return false;
     }
     $ext = strtolower(substr($newName, strrpos($newName, '.') + 1));
     if ($ext != '' && in_array($ext, $this->FileManager->hideFileTypes)) {
         return false;
     }
     if ($this->FileManager->createBackups) {
         $this->createBackup($newName);
     }
     $dst = $this->curDir . '/' . $newName;
     return $this->FileSystem->putFile($src, $dst);
 }
开发者ID:andreyvit,项目名称:retester,代码行数:22,代码来源:Listing.php

示例3: show


//.........这里部分代码省略.........
                         $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) {
                         $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");
                     $info = $result->table($table)->select();
                     cookie('info_page', NULL);
                     cookie('info_step', NULL);
                     $page = 0;
                     $p = 1;
                 }
             }
             if ($info) {
                 while (true) {
                     $t = array_shift($info);
                     $strfile .= $sql->getData($table, $t);
                     if (strlen($strfile) >= $arr_table['filesize'] * 1024) {
                         $filename = $tb . '_' . str_pad($p, 5, "0", STR_PAD_LEFT) . '.bak';
                         $fie_path = $bak_dir . '/' . $filename;
                         $path->putFile($fie_path, $strfile);
                         $p++;
                         $strfile = '';
                         cookie('info_step', $p);
                         $path->putFile(RUNTIME_PATH . '/backup.tmp', serialize($info));
                         echo '<p>表“' . $table . '_' . str_pad($p - 1, 5, "0", STR_PAD_LEFT) . '”备份成功!</p>|1|' . $page;
                         exit;
                     } else {
                         if (count($info)) {
                             continue;
                         } else {
                             break;
                         }
                     }
                 }
             }
             if ($p == 1) {
                 $filename = $tb . '.bak';
                 $fie_path = $bak_dir . '/' . $filename;
                 $path->putFile($fie_path, $strfile);
                 $path->delFile(RUNTIME_PATH . '/backup.tmp');
                 echo '<p>表“' . $table . '”备份成功!</p>|0|0';
                 exit;
             } else {
                 if ($strfile) {
                     $filename = $tb . '_' . str_pad($p, 5, "0", STR_PAD_LEFT) . '.bak';
                     $fie_path = $bak_dir . '/' . $filename;
                     $path->putFile($fie_path, $strfile);
                 }
                 $path->delFile(RUNTIME_PATH . '/backup.tmp');
                 if ($page > 0) {
                     cookie('info_step', $p + 1);
                 }
开发者ID:huangchuping,项目名称:bug,代码行数:67,代码来源:BackupAction.class.php

示例4: 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']}&nbsp;&nbsp;&nbsp;&nbsp;最后检测时间:{$nowdate}";
 }
开发者ID:huangchuping,项目名称:bug,代码行数:22,代码来源:IndexAction.class.php

示例5: 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;
         }
     }
 }
开发者ID:huangchuping,项目名称:bug,代码行数:47,代码来源:MenuAction.class.php


注:本文中的FileSystem::putFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。