本文整理汇总了PHP中utils::cp方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::cp方法的具体用法?PHP utils::cp怎么用?PHP utils::cp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::cp方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multi_dump_sdf
public function multi_dump_sdf($appId, $bakdir)
{
$dirname = $bakdir . '/sdf';
$dbschema_dirname = $bakdir . '/dbschema';
is_dir($dirname) or mkdir($dirname, 0755, true);
is_dir($dbschema_dirname) or mkdir($dbschema_dirname, 0755, true);
$appIds = array_column(app::get('base')->database()->executeQuery('SELECT app_id FROM base_apps WHERE status=?', ['active'])->fetchAll(), 'app_id');
if ($appId) {
$appIds = array_slice($appIds, array_flip($appIds)[$appId]);
$nextAppId = next($appIds);
} else {
$appId = current($appIds);
$nextAppId = next($appIds);
}
if ($appId === false) {
return false;
}
if (is_dir(APP_DIR . '/' . $appId . '/dbschema')) {
foreach (with(new base_application_dbtable())->detect($appId) as $item) {
//echo $item->key();
$columnDefine = $item->load();
$this->dump_data($dirname, $appId, $item->key());
}
utils::cp(APP_DIR . '/' . $appId . '/dbschema', $dbschema_dirname . '/' . $appId);
}
return $nextAppId;
}
示例2: post_install
public function post_install()
{
logger::info('Initial ectools');
kernel::single('base_initial', 'ectools')->init();
logger::info('Initial Regions');
kernel::single('ectools_regions_mainland')->install();
if (!is_dir(DATA_DIR . '/misc')) {
utils::mkdir_p(DATA_DIR . '/misc');
}
utils::cp(app::get('ectools')->res_dir . '/js/region_data.js', DATA_DIR . '/misc/region_data.js');
}
示例3: command_app
function command_app($app_name = null)
{
if (!$app_name) {
$app_name = readline('app name: ');
}
do {
$app_path = APP_DIR . '/' . $app_name;
$app_path = realpath($app_path);
} while (!$appname && strlen($app_path) >= strlen(APP_DIR) && file_exites($app_path));
$base_dir = APP_DIR . '/base';
logger::info('Init App...' . $app_name);
utils::cp($base_dir . '/examples/app', APP_DIR . '/' . $app_name);
utils::replace_p(APP_DIR . '/' . $project_name, array('%*APP_NAME*%' => $project_name));
logger::info('. done!');
return true;
}
示例4: init
function init($name, $template)
{
switch ($template) {
case 'desktop':
$source_dir = APP_DIR . '/base/examples/app';
break;
case 'storage':
$source_dir = APP_DIR . '/base/examples/app';
break;
case 'cache':
$source_dir = APP_DIR . '/base/examples/app';
break;
default:
$source_dir = APP_DIR . '/base/examples/app';
}
kernel::log('Creating application ' . $name . '...');
utils::cp($source_dir, APP_DIR . '/' . $name);
utils::replace_p(APP_DIR . '/' . $name, array('' => $name));
kernel::log('ok.');
return APP_DIR . '/' . $name;
}
示例5: download
public function download($app_id, $force = false)
{
$download_able = $force;
if (!$download_able) {
$download_able = !file_exists(APP_DIR . '/' . $app_id . '/app.xml');
if (!$download_able) {
$rows = app::get('base')->model('apps')->getList('app_id,local_ver,remote_ver', array('app_id' => $app_id), 0, 1);
$download_able = $rows[0]['local_ver'] ? version_compare($rows[0]['remote_ver'], $rows[0]['local_ver'], '>') : true;
}
}
if ($download_able) {
$tmpfile = tempnam(TMP_DIR, 'app_');
$tmpdir = tempnam(TMP_DIR, 'app_');
$download_result = kernel::single('base_pget')->dl(sprintf(URL_APP_FETCH, $app_id), $tmpfile);
if (!$download_result) {
logger::info('Appliction [' . $app_id . '] download failed.');
exit;
}
$broken = false;
logger::info("\nExtra from package.");
foreach (base_package::walk($tmpfile) as $file) {
if (!$file) {
$broken = true;
break;
}
logger::info($file['name']);
base_package::extra($file, $tmpdir);
}
if (!$broken && file_exists($tmpdir . '/app.xml')) {
if (!is_dir(DATA_DIR . '/backup')) {
utils::mkdir_p(DATA_DIR . '/backup');
}
utils::cp(APP_DIR . '/' . $app_id, DATA_DIR . '/backup/app.' . $app_id . '.' . time());
utils::remove_p(APP_DIR . '/' . $app_id);
utils::cp($tmpdir, APP_DIR . '/' . $app_id);
utils::remove_p($tmpdir);
$this->update_local_app_info($app_id);
return true;
} else {
utils::remove_p($tmpdir);
return false;
}
}
}
示例6: command_model
function command_model()
{
if (!($args_input = array_shift(func_get_args()))) {
echo app::get('dev')->_("参数不能为空\n");
echo app::get('dev')->_("用法是: dev:generate model app名(必须):模型层文件夹名:模型层类名(必须):方法名");
return false;
}
$args = explode(':', $args_input);
if (count($args) != 4) {
echo app::get('dev')->_("为空的值也必须占位,格式强制为:\n dev:generate model app名(必须):模型层文件夹名:模型层类名(必须):方法名:") . "\n";
return false;
}
if (!($app_name = trim($args['0']))) {
echo app::get('dev')->_("app名不能为空,请重新输入") . "\n";
return false;
}
$mdl_dir = trim(trim(trim($args['1']), '/'));
if (!($mdl_name = trim($args['2']))) {
echo app::get('dev')->_("模型层类名不能为空,请重新输入") . "\n";
return false;
}
if (!($func_name = trim($args['3']))) {
$func_name = 'default';
}
$replace_map = array('%*APP_NAME*%' => $app_name, '%*MDL_NAME*%' => $mdl_name, '%*FUNC_NAME*%' => $func_name);
//目录为空的时候以"."代替,防止路径出错
if ($mdl_dir != '') {
$replace_map['%*MDL_DIR*%'] = str_replace("/", "_", $mdl_dir) . "_";
} else {
$replace_map['%*MDL_DIR*%'] = '.';
}
$src = APP_DIR . "/dev/demo";
$dst = APP_DIR . "/" . $app_name;
if (!file_exists($dst)) {
echo app::get('dev')->_("找不到 名为 {$app_name} 的app ");
return false;
}
$src_sample_mdl_path = "{$src}/sample_mdl.php";
//demo下的后台控制器sample文件路径
$dst_sample_mdl_path = "{$dst}/model/{$mdl_dir}/sample_mdl.php";
//新建的app下的后台控制器sample文件路径
$dst_mdl_path = "{$dst}/model/{$mdl_dir}/{$mdl_name}.php";
//新建的app的控制器文件路径
if (file_exists($dst_mdl_path)) {
echo app::get('dev')->_("模型层类 {$mdl_name}.php 已经存在 ") . "\n";
do {
$install_confirm = readline('是否覆盖? [Y/n] ');
switch (strtolower(trim($install_confirm))) {
case 'y':
$install_confirm = true;
$command_succ = true;
break;
case 'n':
$install_confirm = false;
$command_succ = true;
break;
default:
$command_succ = false;
}
} while (!$command_succ);
if (!$install_confirm) {
return false;
}
}
kernel::log('开始创建模型层...');
$this->mkdir_r("{$dst}/model/{$mdl_dir}", 0755);
utils::cp($src_sample_mdl_path, $dst_sample_mdl_path);
rename($dst_sample_mdl_path, $dst_mdl_path);
utils::replace_in_file($dst_mdl_path, $replace_map);
kernel::log("创建模型层文件 {$mdl_name}.php");
kernel::log("创建完成!");
}
示例7: command_createproject
function command_createproject($project_path = null, $install_confirm = null)
{
if (!$project_path) {
$project_path = readline('Project path: ');
}
while (file_exists($project_path)) {
$project_path = readline('Project already exists. enter anthoer one: ');
}
$project_name = basename($project_path);
//init files
$base_dir = dirname(__FILE__) . '/../../';
kernel::log('Init project... ' . realpath($project_path . '/' . $project_name), 1);
utils::cp($base_dir . '/examples/project', $project_path);
utils::cp($base_dir, $project_path . '/app/base');
utils::cp($base_dir . '/examples/app', $project_path . '/app/' . $project_name);
chmod($project_path . '/app/base/cmd', 0744);
chmod($project_path . '/data', 0777);
utils::replace_p($project_path . '/config', array('' => $project_name));
utils::replace_p($project_path . '/app/' . $project_name, array('' => $project_name));
kernel::log('. done!');
if ($install_confirm === null) {
do {
$install_confirm = readline('Install now? [Y/n] ');
switch (strtolower(trim($install_confirm))) {
case '':
case 'y':
$install_confirm = true;
$command_succ = true;
break;
case 'n':
$install_confirm = false;
$command_succ = true;
break;
default:
$command_succ = false;
}
} while (!$command_succ);
}
$install_command = 'app' . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'cmd install ' . $project_name;
if ($install_confirm) {
kernel::log('Installing...');
kernel::log("\n" . $project_path . ' > ' . $install_command . "\n");
chdir($project_path);
passthru($install_command);
} else {
"Change dir to {$project_dir}: " . $install_command;
}
}
示例8: write_config
public static function write_config()
{
return utils::cp(ROOT_DIR . '/app/base/examples/queue.php', ROOT_DIR . '/config/queue.php');
}
示例9: copyTheme
/**
* 复制CPS模板
* @access private
* @param string $theme 安装的模板名
*/
private function copyTheme($theme)
{
$themeDir = app::get('cps')->app_dir . '/init_tmpl';
$destDir = ROOT_DIR . '/themes/' . $theme;
utils::cp($themeDir, $destDir);
}
示例10: multi_dump_sdf
public function multi_dump_sdf($app, $bakdir)
{
$dirname = $bakdir . '/sdf';
$dbschema_dirname = $bakdir . '/dbschema';
is_dir($dirname) or mkdir($dirname, 0755, true);
is_dir($dbschema_dirname) or mkdir($dbschema_dirname, 0755, true);
$sql = 'SELECT app_id FROM sdb_base_apps WHERE status=\'active\'';
$tables = $this->_db->select($sql);
if ($app) {
foreach ($tables as $key => $name) {
if ($app == $name['app_id']) {
$tables = array_slice($tables, $key);
break;
}
}
}
$i = 0;
foreach ($tables as $key => $tbl) {
$app = $tbl['app_id'];
$service = false;
foreach (kernel::servicelist('desktop_backup.' . $app) as $object) {
$service = true;
$m = substr(get_class($object), strpos(get_class($object), $app) + strlen($app) + strlen('_mdl_'));
$this->dump_data($dirname, $app, $m);
}
if (!$service) {
if (!is_dir(APP_DIR . '/' . $app . '/dbschema')) {
if (count($tables) == 1) {
return false;
} else {
$arr = $tables[$key + 1];
return $arr['app_id'];
}
break;
}
if ($handle = opendir(APP_DIR . '/' . $app . '/dbschema')) {
chdir(APP_DIR . '/' . $app . '/dbschema');
while (false !== ($file = readdir($handle))) {
if ($file[0] != '.') {
if (strtolower(substr($file, -strpos(strrev($file), '.'))) != 'php') {
if (count($tables) == 1) {
return false;
} else {
$arr = $tables[$key + 1];
return $arr['app_id'];
}
break;
}
require $file;
}
}
closedir($handle);
}
if (!is_array($db)) {
if (count($tables) == 1) {
return false;
} else {
$arr = $tables[$key + 1];
return $arr['app_id'];
}
break;
}
foreach ($db as $m => $row) {
if ($row['unbackup']) {
continue;
}
$this->dump_data($dirname, $app, $m);
}
}
utils::cp(APP_DIR . '/' . $app . '/dbschema', $dbschema_dirname . '/' . $app);
if (count($tables) == 1) {
return false;
} else {
$arr = $tables[$key + 1];
return $arr['app_id'];
}
}
return false;
}