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


PHP create_dir_or_files函数代码示例

本文整理汇总了PHP中create_dir_or_files函数的典型用法代码示例。如果您正苦于以下问题:PHP create_dir_or_files函数的具体用法?PHP create_dir_or_files怎么用?PHP create_dir_or_files使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: build

    public function build()
    {
        $data = $_POST;
        $data['info']['name'] = trim($data['info']['name']);
        $addonFile = $this->preview(false);
        $addons_dir = ONETHINK_ADDON_PATH;
        //创建目录结构
        $files = array();
        $addon_dir = "{$addons_dir}{$data['info']['name']}/";
        $files[] = $addon_dir;
        $addon_name = "{$data['info']['name']}Addon.class.php";
        $files[] = "{$addon_dir}{$addon_name}";
        if ($data['has_config'] == 1) {
        }
        //如果有配置文件
        $files[] = $addon_dir . 'config.php';
        if ($data['has_outurl']) {
            $files[] = "{$addon_dir}Controller/";
            $files[] = "{$addon_dir}Controller/{$data['info']['name']}Controller.class.php";
            $files[] = "{$addon_dir}Model/";
            $files[] = "{$addon_dir}Model/{$data['info']['name']}Model.class.php";
        }
        $custom_config = trim($data['custom_config']);
        if ($custom_config) {
            $data[] = "{$addon_dir}{$custom_config}";
        }
        $custom_adminlist = trim($data['custom_adminlist']);
        if ($custom_adminlist) {
            $data[] = "{$addon_dir}{$custom_adminlist}";
        }
        create_dir_or_files($files);
        //写文件
        file_put_contents("{$addon_dir}{$addon_name}", $addonFile);
        if ($data['has_outurl']) {
            $addonController = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Controller;
use Home\\Controller\\AddonsController;

class {$data['info']['name']}Controller extends AddonsController{

}

str;
            file_put_contents("{$addon_dir}Controller/{$data['info']['name']}Controller.class.php", $addonController);
            $addonModel = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Model;
use Think\\Model;

/**
 * {$data['info']['name']}模型
 */
class {$data['info']['name']}Model extends Model{

}

str;
            file_put_contents("{$addon_dir}Model/{$data['info']['name']}Model.class.php", $addonModel);
        }
        if ($data['has_config'] == 1) {
            file_put_contents("{$addon_dir}config.php", $data['config']);
        }
        $this->success('创建成功', U('index'));
    }
开发者ID:youwen21,项目名称:ot2,代码行数:67,代码来源:AddonsController.class.php

示例2: build

    public function build()
    {
        $data = $_POST;
        $data['info']['name'] = trim($data['info']['name']);
        $addonFile = $this->preview(false);
        $addons_dir = ONETHINK_ADDON_PATH;
        //创建目录结构
        $files = array();
        $addon_dir = "{$addons_dir}{$data['info']['name']}/";
        $files[] = $addon_dir;
        $addon_name = "{$data['info']['name']}Addon.class.php";
        $files[] = "{$addon_dir}{$addon_name}";
        if ($data['has_config'] == 1) {
        }
        //如果有配置文件
        $files[] = $addon_dir . 'config.php';
        if ($data['has_outurl']) {
            $files[] = "{$addon_dir}Controller/";
            $files[] = "{$addon_dir}Controller/{$data['info']['name']}Controller.class.php";
            $files[] = "{$addon_dir}Model/";
            $files[] = "{$addon_dir}Model/{$data['info']['name']}Model.class.php";
        }
        $custom_config = trim($data['custom_config']);
        if ($custom_config) {
            $data[] = "{$addon_dir}{$custom_config}";
        }
        $custom_adminlist = trim($data['custom_adminlist']);
        if ($custom_adminlist) {
            $data[] = "{$addon_dir}{$custom_adminlist}";
        }
        create_dir_or_files($files);
        //写文件
        file_put_contents("{$addon_dir}{$addon_name}", $addonFile);
        if ($data['has_outurl']) {
            $addonController = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Controller;
use Home\\Controller\\AddonsController;

class {$data['info']['name']}Controller extends AddonsController{

}

str;
            file_put_contents("{$addon_dir}Controller/{$data['info']['name']}Controller.class.php", $addonController);
            $addonModel = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Model;
use Think\\Model;

/**
 * {$data['info']['name']}模型
 */
class {$data['info']['name']}Model extends Model{
    public \$model = array(
        'title'=>'',//新增[title]、编辑[title]、删除[title]的提示
        'template_add'=>'',//自定义新增模板自定义html edit.html 会读取插件根目录的模板
        'template_edit'=>'',//自定义编辑模板html
        'search_key'=>'',// 搜索的字段名,默认是title
        'extend'=>1,
    );

    public \$_fields = array(
        'id'=>array(
            'name'=>'id',//字段名
            'title'=>'ID',//显示标题
            'type'=>'num',//字段类型
            'remark'=>'',// 备注,相当于配置里的tip
            'is_show'=>3,// 1-始终显示 2-新增显示 3-编辑显示 0-不显示
            'value'=>0,//默认值
        ),
        'title'=>array(
            'name'=>'title',
            'title'=>'书名',
            'type'=>'string',
            'remark'=>'',
            'is_show'=>1,
            'value'=>0,
            'is_must'=>1,
        ),
    );
}

str;
            file_put_contents("{$addon_dir}Model/{$data['info']['name']}Model.class.php", $addonModel);
        }
        if ($data['has_config'] == 1) {
            file_put_contents("{$addon_dir}config.php", $data['config']);
        }
        $this->success('创建成功', U('index'));
    }
开发者ID:WineShop,项目名称:wine,代码行数:93,代码来源:AddonsController.class.php

示例3: tpllists

 public function tpllists()
 {
     if (IS_POST) {
         $info = I('post.');
         if ($info['createtype'] == 'dir') {
             $file_ext = explode('.', $info['createname']);
             if (!empty($file_ext[1]) || preg_match('/[^\\x00-\\x80]/', $info['createname'])) {
                 $this->error('文件夹名称应为英文字符和数字');
             }
             $filepath = $this->setFullpath($info['createpath'], $info['createname'], '');
             if (is_dir($filepath)) {
                 $this->error('该文件(文件夹)已经存在,请换个标识');
             } else {
                 create_dir_or_files(array(0 => $filepath));
                 $this->success($info['createname'] . '文件夹创建成功!路径为:' . $filepath, U('edit'));
             }
         } else {
             import('Common.ORG.Input');
             $content = \Input::getVar($info['content']);
             $file_ext = explode('.', $info['createname']);
             if (count($file_ext) > 0) {
                 $ext = end($file_ext);
                 $filename = str_replace('.' . $ext, '', $info['createname']);
                 //创建路径 file_put_contents("{$addon_dir}Model/{$data['info']['name']}Model.class.php", $addonModel);
                 $filepath = $this->setFullpath($info['createpath'], $filename, $ext);
                 //判断文件是否存在 否则创建
                 if (!file_exists($filepath)) {
                     create_dir_or_files(array(0 => $filepath));
                     //是否存在
                     if (!file_exists($filepath)) {
                         $this->error('模板文件新建失败,后缀标识为.,请确保文件名请使用非中文和标点,当前路径为合法路径');
                     }
                 }
                 if (!is_writable($filepath)) {
                     $this->error("文件 {$info['createname']} 不可写!");
                 }
                 file_put_contents($filepath, $content);
                 $this->success('创建【' . $info['createname'] . '】文件成功!', U('edit'));
             } else {
                 $this->error('请输入有效的文件后缀名!');
             }
         }
     } else {
         $this->assign('meta_title', '模板编辑');
         $info = I('get.');
         if (empty($info['type'])) {
             $filename = $info['filename'];
             $showpath = str_replace('-', '/', $info['dir']) . '/' . $info['filename'];
             $this->assign('editpath', $showpath);
             $this->assign('title', '新增');
             $this->assign('nowpath', $showpath);
         } else {
             $filename = $info['filename'] . '.' . $info['type'];
             $showpath = str_replace('-', '/', $info['dir']);
             $filepath = $this->setFullpath($info['dir'], $info['filename'], $info['type']);
             //标签合法
             $content = file_get_contents($filepath);
             import('Common.ORG.Input');
             $content = \Input::forTarea($content);
             $this->assign('content', $content);
             $this->assign('title', '编辑');
             $this->assign('editpath', $showpath);
             $this->assign('nowpath', $showpath . '/' . $filename);
             $this->assign('fileinfo', $filename);
             $this->assign('filetype', 'file');
         }
         $this->display();
     }
 }
开发者ID:wmk223,项目名称:amango_V3,代码行数:69,代码来源:ThemeController.class.php

示例4: build

    public function build()
    {
        $data = $_POST;
        $data['info']['name'] = trim($data['info']['name']);
        $addonFile = $this->preview(false);
        $addons_dir = ONETHINK_ADDON_PATH;
        //创建目录结构
        $files = array();
        $addon_dir = "{$addons_dir}{$data['info']['name']}/";
        $files[] = $addon_dir;
        $addon_name = "{$data['info']['name']}Addon.class.php";
        $files[] = "{$addon_dir}{$addon_name}";
        if ($data['has_config'] == 1) {
            $files[] = $addon_dir . 'config.php';
        }
        if ($data['has_outurl'] || $data['type'] == 1) {
            $files[] = "{$addon_dir}Controller/";
            $files[] = "{$addon_dir}Controller/{$data['info']['name']}Controller.class.php";
            $files[] = "{$addon_dir}Model/";
            $files[] = "{$addon_dir}Model/{$data['info']['name']}Model.class.php";
            $files[] = "{$addon_dir}View/";
            $files[] = "{$addon_dir}View/default/";
            $files[] = "{$addon_dir}View/default/{$data['info']['name']}/";
        }
        $custom_config = trim($data['custom_config']);
        if ($custom_config) {
            $data[] = "{$addon_dir}{$custom_config}";
        }
        $custom_adminlist = trim($data['custom_adminlist']);
        if ($custom_adminlist) {
            $data[] = "{$addon_dir}{$custom_adminlist}";
        }
        create_dir_or_files($files);
        //写文件
        file_put_contents("{$addon_dir}{$addon_name}", $addonFile);
        if ($data['has_outurl']) {
            $addonController = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Controller;
use Home\\Controller\\AddonsController;

class {$data['info']['name']}Controller extends AddonsController{

}

str;
            file_put_contents("{$addon_dir}Controller/{$data['info']['name']}Controller.class.php", $addonController);
            $addonModel = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Model;
use Think\\Model;

/**
 * {$data['info']['name']}模型
 */
class {$data['info']['name']}Model extends Model{

}

str;
            file_put_contents("{$addon_dir}Model/{$data['info']['name']}Model.class.php", $addonModel);
        }
        if ($data['type'] == 1) {
            $addonModel = <<<str
<?php
        \t
namespace Addons\\{$data['info']['name']}\\Model;
use Home\\Model\\WeixinModel;
        \t
/**
 * {$data['info']['name']}的微信模型
 */
class WeixinAddonModel extends WeixinModel{
\tfunction reply(\$dataArr, \$keywordArr = array()) {
\t\t\$config = getAddonConfig ( '{$data['info']['name']}' ); // 获取后台插件的配置参数\t
\t\t//dump(\$config);

\t} 

\t// 关注公众号事件
\tpublic function subscribe() {
\t\treturn true;
\t}
\t
\t// 取消关注公众号事件
\tpublic function unsubscribe() {
\t\treturn true;
\t}
\t
\t// 扫描带参数二维码事件
\tpublic function scan() {
\t\treturn true;
\t}
\t
\t// 上报地理位置事件
\tpublic function location() {
\t\treturn true;
\t}
//.........这里部分代码省略.........
开发者ID:Backflag,项目名称:weiphp2.0.1202,代码行数:101,代码来源:AddonsController.class.php

示例5: write_config

/**
 * 写入配置文件
 * @param  array $config 配置信息
 */
function write_config($config, $auth)
{
    if (is_array($config)) {
        //读取配置内容
        $conf = file_get_contents(MODULE_PATH . 'Data/conf.tpl');
        $user = file_get_contents(MODULE_PATH . 'Data/user.tpl');
        //替换配置项
        foreach ($config as $name => $value) {
            $conf = str_replace("[{$name}]", $value, $conf);
            $user = str_replace("[{$name}]", $value, $user);
        }
        $conf = str_replace('[AUTH_KEY]', $auth, $conf);
        $user = str_replace('[AUTH_KEY]', $auth, $user);
        //写入应用配置文件
        if (!IS_WRITE) {
            return '由于您的环境不可写,请复制下面的配置文件内容覆盖到相关的配置文件,然后再登录后台。<p>' . realpath(APP_PATH) . '/Common/Conf/config.php</p>
			<textarea name="" style="width:650px;height:185px">' . $conf . '</textarea>
			<p>' . realpath(APP_PATH) . '/User/Conf/config.php</p>
			<textarea name="" style="width:650px;height:125px">' . $user . '</textarea>';
        } else {
            //判断文件是否存在 不存在就自动创建  兼容
            $commonconfig = APP_PATH . 'Common/Conf/config.php';
            $userconfig = APP_PATH . 'User/Conf/config.php';
            if (!file_exists($commonconfig)) {
                $files[] = $commonconfig;
            }
            if (!file_exists($userconfig)) {
                $files[] = $userconfig;
            }
            if (!empty($files)) {
                create_dir_or_files($files);
            }
            if (file_put_contents($commonconfig, $conf) && file_put_contents($userconfig, $user)) {
                show_msg('配置文件写入成功');
            } else {
                //写入失败则删除
                if (!empty($files)) {
                    foreach ($files as $key => $value) {
                        unlink($value);
                    }
                }
                show_msg('配置文件写入失败!', 'error');
                session('error', true);
            }
            return '';
        }
    }
}
开发者ID:fedkey,项目名称:amango,代码行数:52,代码来源:function.php

示例6: build

    public function build()
    {
        $data = $_POST;
        //根据标签生成微信方法
        $tagslist = parse_config($data['tagslists']);
        //去掉空标签配置
        foreach ($tagslist as $key => $value) {
            if (empty($key)) {
                unset($tagslist[$key]);
            }
        }
        $autotagaction = '';
        foreach ($tagslist as $key => $value) {
            if (substr_count($value, '/') == 0) {
                $autotagaction .= <<<str
        //实现的{$value}微信TAG方法
        public function {$value}(\$param){
            return '实现的{$value}微信TAG方法';
        }

str;
            }
        }
        $data['info']['name'] = trim($data['info']['name']);
        $addonFile = $this->preview(false);
        $addons_dir = ONETHINK_ADDON_PATH;
        //创建目录结构
        $files = array();
        $addon_dir = "{$addons_dir}{$data['info']['name']}/";
        $files[] = $addon_dir;
        $addon_name = "{$data['info']['name']}Addon.class.php";
        $files[] = "{$addon_dir}{$addon_name}";
        if ($data['has_config'] == 1) {
        }
        //如果有配置文件
        $files[] = $addon_dir . 'config.php';
        if ($data['has_org'] == 1) {
        }
        //如果有自定义类
        $files[] = "{$addon_dir}ORG/";
        if ($data['has_outurl']) {
            //生成插件控制器
            $files[] = "{$addon_dir}Controller/";
            $files[] = "{$addon_dir}Controller/{$data['info']['name']}Controller.class.php";
            $files[] = "{$addon_dir}Controller/HomeController.class.php";
            $files[] = "{$addon_dir}Controller/WeixinController.class.php";
            $files[] = "{$addon_dir}Model/";
            $files[] = "{$addon_dir}Model/{$data['info']['name']}Model.class.php";
            //生成资源文件
            $files[] = "{$addon_dir}Public/";
            //生成模板文件
            $files[] = "{$addon_dir}View/";
            $files[] = "{$addon_dir}View/default/";
            $files[] = "{$addon_dir}View/default/Home/";
            $files[] = "{$addon_dir}View/default/Home/index.html";
            $files[] = "{$addon_dir}View/default/Home/profile.html";
        }
        $custom_config = trim($data['custom_config']);
        if ($custom_config) {
            $data[] = "{$addon_dir}{$custom_config}";
        }
        $custom_adminlist = trim($data['custom_adminlist']);
        if ($custom_adminlist) {
            $data[] = "{$addon_dir}{$custom_adminlist}";
        }
        create_dir_or_files($files);
        //写文件
        file_put_contents("{$addon_dir}{$addon_name}", $addonFile);
        if ($data['has_outurl']) {
            //创建  插件名Controller
            $addonController = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Controller;
use Home\\Controller\\AddonsController;

class {$data['info']['name']}Controller extends AddonsController{

}

str;
            file_put_contents("{$addon_dir}Controller/{$data['info']['name']}Controller.class.php", $addonController);
            //创建  HomeController
            $homeController = <<<str
<?php

namespace Addons\\{$data['info']['name']}\\Controller;
use Home\\Controller\\AddonsController;

class HomeController extends AddonsController{
    /**
     * 开发说明:三大全局变量  global \$_W,\$_K;            W[网站信息]  K[默认微信公众号信息]
     *                        session('P');              前台用户信息
     *          获取插件配置  get_addon_config(\$name);
     */
    //插件前台展示页面
    public function index(){
        \$this->display();
    }
    //插件Tips返回处理 return 数字
//.........这里部分代码省略.........
开发者ID:fedkey,项目名称:amango,代码行数:101,代码来源:AddonsController.class.php


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