public static function createProject($argProjectName = '') { $conName = PROJECT_NAME . "Configure"; debug('$argProjectName=' . $argProjectName); $samplePackage = $conName::SAMPLE_PROJECT_PACKAGE_PATH; $newProjectName = str_replace('Package', '', ucfirst($argProjectName . basename($samplePackage))); debug('$newProjectName=' . $newProjectName); // 移動先のパス $movePath = dirname($conName::PROJECT_ROOT_PATH) . '/' . $newProjectName . 'Package'; debug('$movePath=' . $movePath); if (!dir_copy($samplePackage, $movePath)) { return FALSE; } // プロジェクト名が指定されている場合は、デフォルトの定義を書き換えて上げる為の処理 if ('' !== $argProjectName) { // config.xmlのファイル名を書き換える $newConfigXMLPath = $movePath . '/core/' . $newProjectName . '.config.xml'; rename($movePath . '/core/Project.config.xml', $newConfigXMLPath); // package.xmlのファイル名を書き換える rename($movePath . '/core/Project.package.xml', $movePath . '/core/' . $newProjectName . '.package.xml'); // config.xml内のプロジェクト名を書き換える $configXMLStr = file_get_contents($newConfigXMLPath); $configXMLStr = str_replace(array('<Project>', '</Project>'), array('<' . $newProjectName . '>', '</' . $newProjectName . '>'), $configXMLStr); // 新しい定義で書き換え file_put_contents($newConfigXMLPath, $configXMLStr); // 重いのでコマメにunset unset($configXMLStr); // installer内のプロジェクト名を書き換える $installerStr = file_get_contents($movePath . '/installer.php'); $installerStr = str_replace('$projectpkgName = "Project";', '$projectpkgName = "' . ucfirst($newProjectName) . '";', $installerStr); // 新しい定義で書き換え file_put_contents($movePath . '/installer.php', $installerStr); // 重いのでコマメにunset unset($installerStr); // RESRAPI-index内のプロジェクト名を書き換える $apidocPath = $movePath . '/apidocs'; $apiIndexStr = file_get_contents($apidocPath . '/index.php'); $apiIndexStr = str_replace('$projectpkgName = "Project";', '$projectpkgName = "' . ucfirst($newProjectName) . '";', $apiIndexStr); // 新しい定義で書き換え file_put_contents($movePath . '/apidocs/index.php', $apiIndexStr); // 重いのでコマメにunset unset($apiIndexStr); // iOSサンプル内のプロジェクト内のRESTfulAPIの向け先を帰る $iosdefineStr = file_get_contents($movePath . '/iOSSample/Project/SupportingFiles/define.h'); // レビュー用の暫定処理 $basePath = str_replace('/' . PROJECT_NAME . '/', '|', $_SERVER["REQUEST_URI"]); $basePaths = explode('|', $basePath); $iosdefineStr = str_replace('# define URL_BASE @"/workspace/UNICORN/src/lib/FrameworkManager/template/managedocs/"', '# define URL_BASE @"' . $basePaths[0] . '/' . $newProjectName . 'Package/apidocs/' . '"', $iosdefineStr); // 新しい定義で書き換え file_put_contents($movePath . '/iOSSample/Project/SupportingFiles/define.h', $iosdefineStr); // 重いのでコマメにunset unset($iosdefineStr); } return TRUE; }
function dir_copy($src, $dst) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { dir_copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); }
function dir_copy($dir_name, $new_dir) { if (!is_dir($new_dir)) { mkdir($new_dir); } if (is_dir($dir_name)) { if ($dh = opendir($dir_name)) { while (($file = readdir($dh)) !== false) { if ($file == "." || $file == "..") { continue; } if (is_dir($dir_name . "/" . $file)) { dir_copy($dir_name . "/" . $file, $new_dir . "/" . $file); } else { copy($dir_name . "/" . $file, $new_dir . "/" . $file); } } closedir($dh); } } return true; }
function insert() { $lang_path = LANG_PATH . $_POST['mark'] . '/'; $r = dir_copy(LANG_PATH . 'cn/', $lang_path); $name = MODULE_NAME; $model = D($name); if (false === $model->create()) { $this->error($model->getError()); } $id = $model->add(); if ($id !== false) { $db = D(''); $db = DB::getInstance(); $db->execute("INSERT INTO `yourphp_config` (`varname`,`info`,`groupid`,`value`,`lang`) VALUES ('site_name','网站名称','2','','" . $id . "'),\n\t\t\t('site_url','网站网址','2','','" . $id . "'),\n\t\t\t('logo','网站LOGO','2','./Public/Images/logo.gif','" . $id . "'),\n\t\t\t('site_email','站点邮箱','2','*****@*****.**','" . $id . "'),\n\t\t\t('seo_title','网站标题','2','','" . $id . "'),\n\t\t\t('seo_keywords','关键词','2','','" . $id . "'),\n\t\t\t('seo_description','网站简介','2','','" . $id . "'),\n\t\t\t('member_register','允许新会员注册','3','1','" . $id . "'),\n\t\t\t('member_emailcheck','新会员注册需要邮件验证','3','0','" . $id . "'),\n\t\t\t('member_registecheck','新会员注册需要审核','3','1','" . $id . "'),\n\t\t\t('member_login_verify','注册登陆开启验证码','3','1','" . $id . "'),\n\t\t\t('member_emailchecktpl','邮件认证模板','3','','" . $id . "'),\n\t\t\t('member_getpwdemaitpl','密码找回邮件内容','3','','" . $id . "')\n\t\t\t;"); if (in_array($name, $this->cache_model)) { savecache($name); } $jumpUrl = $_POST['forward'] ? $_POST['forward'] : U(MODULE_NAME . '/index'); $this->assign('jumpUrl', $jumpUrl); $this->success(L('add_ok')); } else { $this->error(L('add_error') . ': ' . $model->getDbError()); } }
/** * 拷贝目录及下面所有文件 * * @param string $fromdir 原路径 * @param string $todir 目标路径 * @return string 如果目标路径不存在则返回false,否则为true */ function dir_copy($fromdir, $todir) { $fromdir = dir_path($fromdir); $todir = dir_path($todir); if (!is_dir($fromdir)) { return FALSE; } if (!is_dir($todir)) { dir_create($todir); } $list = glob($fromdir . '*'); if (!empty($list)) { foreach ($list as $v) { $path = $todir . basename($v); if (is_dir($v)) { dir_copy($v, $path); } else { copy($v, $path); @chmod($path, 0777); } } } return TRUE; }
// Fetch the site. $site =& new Site($sitename); $site->fetchDown(TRUE); $site->fetchSiteAtOnceForeverAndEverAndDontForgetThePermissionsAsWell_Amen(); // Fetch the location of the media files. $imagepath = $uploaddir . '/' . $sitename . '/'; // Get the XML for the site $siteExporter =& new DomitSiteExporter(); $siteXML =& $siteExporter->export($site); // make a directory for the site contents $siteDir = $exportpath . '/' . $sitename . '/'; if (file_exists($siteDir)) { deletePath($siteDir); } mkdir($siteDir); // Copy the Media Files to the sitedir. dir_copy($imagepath, $siteDir . 'media/'); // Save the XML to a file. $xmlFile = $siteDir . 'site.xml'; if (!($handle = fopen($xmlFile, 'a'))) { echo "Cannot open file ({$xmlFile})"; exit; } // Write $somecontent to our opened file. if (!fwrite($handle, $siteXML)) { echo "Cannot write to file ({$xmlFile})"; exit; } fclose($handle); } exit(0);
$do_enable = $n_operated || !isset($stepeds['freeinfos']) ? false : true; //如果上一步没有完成,这一步不能开始 $undo_enable = !$n_operated ? false : true; //如果上一步没有撤消,这一步不能撤消 $true_tpldir = M_ROOT . "./template/" . $subsites[$nsid]['templatedir'] . '/'; if (!submitcheck('bdo') && !submitcheck('bundo')) { tabheader(lang('subtemtra') . ' - ' . ($n_operated ? ' Y' : ' N'), 'templates', '?entry=subsetup&action=templates'); echo "<tr class=\"txt\"><td class=\"txtC\" colspan=\"2\"><br>"; echo empty($n_operated) ? lang('templatesdo') : lang('templatesundo'); echo "<br><br></td></tr>"; tabfooter(); echo "<input class=\"button\" type=\"submit\" name=\"bdo\" value=\"" . lang('nextstep') . "\"" . ($do_enable ? '' : ' disabled') . "> "; echo "<input class=\"button\" type=\"submit\" name=\"bundo\" value=\"" . lang('undosetting') . "\"" . ($undo_enable ? '' : ' disabled') . "> "; echo "</form>\n"; } elseif (submitcheck('bdo')) { if (!dir_copy($subsetupdir . 'template/', $true_tpldir, 1, 1)) { amessage('telcopyerror'); } $tagsarr = $tplsarr = array(); $omtpls = oread_cache('mtpls', '', '', 'template'); foreach ($omtpls as $k => $v) { $tplsarr[] = $k; } $osptpls = oread_cache('sptpls', '', '', 'template'); foreach ($osptpls as $k => $v) { $tplsarr[] = $v; } foreach ($tplsarr as $v) { $str = @file2str($subsetupdir . 'template/' . $v); oreplace($str, 'p'); oreplace($str, 'c');
if ($password == $oldpassword) { msg('新密码不能与现有密码相同'); } $password = md5(md5($password)); $db->query("UPDATE {$DT_PRE}member SET password='******' WHERE userid='{$_userid}'"); userclean($_username); msg('管理员密码修改成功', '?action=main'); } else { include tpl('password'); } break; case 'static': if ($itemid) { foreach (array(DT_ROOT . '/file/flash/', DT_ROOT . '/file/image/', DT_ROOT . '/file/script/', DT_ROOT . '/skin/' . $CFG['skin'] . '/', DT_ROOT . '/' . $MODULE[2]['moduledir'] . '/image/', DT_ROOT . '/' . $MODULE[4]['moduledir'] . '/skin/') as $d) { $s = str_replace(DT_ROOT, DT_ROOT . '/file/static', $d); dir_copy($d, $s); } foreach (array(DT_ROOT . '/favicon.ico', DT_ROOT . '/lang/' . DT_LANG . '/lang.js') as $d) { $s = str_replace(DT_ROOT, DT_ROOT . '/file/static', $d); file_copy($d, $s); } } include tpl('static'); break; case 'side': $files = glob(DT_CACHE . '/*.part'); $spart = 0; if ($files) { foreach ($files as $f) { $mid = basename($f, '.part'); if (!isset($MODULE[$mid])) {
function dir_copy($fromdir, $todir) { $fromdir = dir_path($fromdir); $todir = dir_path($todir); if (!is_dir($fromdir)) { return false; } if (!is_dir($todir)) { dir_create($todir); } $list = glob($fromdir . '*'); foreach ($list as $v) { $path = $todir . basename($v); if (is_file($path) && !is_writable($path)) { if (DT_CHMOD) { @chmod($path, DT_CHMOD); } } if (is_dir($v)) { dir_copy($v, $path); } else { @copy($v, $path); if (DT_CHMOD) { @chmod($path, DT_CHMOD); } } } return true; }
function dir_copy($from_path, $to_path) { // posted by dallask at sbcglobal dot net 21-Oct-2002 10:14 // on PHP.net // Recursively copies a directory. $this_path = getcwd(); if (!is_dir($to_path)) { mkdir($to_path, 0775); } if (is_dir($from_path)) { chdir($from_path); $handle = opendir('.'); while (($file = readdir($handle)) !== false) { if ($file != "." && $file != "..") { if (is_dir($file)) { chdir($this_path); dir_copy($from_path . $file . "/", $to_path . $file . "/"); chdir($this_path); chdir($from_path); } if (is_file($file)) { chdir($this_path); copy($from_path . $file, $to_path . $file); chdir($from_path); } } } closedir($handle); } chdir($this_path); }
/** * ディレクトリごと移動(コピーして削除)する */ function dir_move($dir_name, $new_dir, $permission = 0755) { if (TRUE === dir_copy($dir_name, $new_dir, $permission)) { // コピーに成功してから削除する // XXX 冗長だが敢えて return dir_delete($dir_name); return TRUE; } return FALSE; }
public function create() { chdir(ROOT_DIR); dir_copy(ROOT_DIR . '/repository', INSTALL_PATH); }
/** * 将一个文件夹内容,复制或移动到另一个文件夹 * * @param string $source 源文件夹名 * @param string $target 目标文件夹 * @param boolean $deleteSource 是否删除源文件夹(是则相当于移动,否则相当于复制) * * @return boolean */ function dir_copy($source, $target, $deleteSource = false) { $source = dir_format($source); $target = dir_format($target); if ($source == $target) { return true; } if (!is_dir($source)) { return false; } dir_check($target); $handle = opendir($source); if (!$handle) { return false; } $sourcePath = $targetPath = ''; while (($item = readdir($handle)) !== false) { if ($item == '.' || $item == '..') { continue; } $sourcePath = $source . '/' . $item; $targetPath = $target . '/' . $item; if (is_dir($sourcePath)) { dir_copy($sourcePath, $targetPath, $deleteSource); if ($deleteSource) { rmdir($sourcePath); } } else { copy($sourcePath, $targetPath); if ($deleteSource) { unlink($sourcePath); } } } closedir($handle); return true; }
/** * ディレクトリごと移動(コピーして削除)する */ function dir_move($dir_name, $new_dir) { if (true === dir_copy($dir_name, $new_dir)) { // コピーに成功してから削除する // XXX 冗長だが敢えて //return dir_delete($dir_name); return true; } return false; }
function dir_copy($source, $destination, $f = 0, $d = 0) { //$f-是否复制文件夹下文件,$d是否复制搜索下级文件夹 if (!is_dir($source)) { return false; } mmkdir($destination, 0); if ($f || $d) { $handle = dir($source); while ($entry = $handle->read()) { if ($entry != "." && $entry != "..") { if (is_dir($source . "/" . $entry)) { $d && dir_copy($source . "/" . $entry, $destination . "/" . $entry, $f, $d); } else { $f && copy($source . "/" . $entry, $destination . "/" . $entry); } } } } return true; }
function dir_copy($source, $destination, $child) { if (!is_dir($destination)) { mkdir($destination, 0777, true); } $handle = dir($source); while ($entry = $handle->read()) { if (!in_array($entry, array('.', '..', '.svn'))) { if (is_dir($source . "/" . $entry)) { if ($child) { dir_copy($source . "/" . $entry, $destination . "/" . $entry, $child); } } else { copy($source . "/" . $entry, $destination . "/" . $entry); } } } return true; }
/** * 模块安装 * @param string $module 模块名 */ public function install($module = '') { define('INSTALL', true); if ($module) { $this->module = $module; } $this->installdir = PC_PATH . 'modules' . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR; $this->check(); $models = @(require $this->installdir . 'model.php'); if (!is_array($models) || empty($models)) { $models = array('module'); } if (!in_array('module', $models)) { array_unshift($models, 'module'); } if (is_array($models) && !empty($models)) { foreach ($models as $m) { $this->m_db = pc_base::load_model($m . '_model'); $sql = file_get_contents($this->installdir . $m . '.sql'); $this->sql_execute($sql); } } if (file_exists($this->installdir . 'extention.inc.php')) { $menu_db = pc_base::load_model('menu_model'); @(include $this->installdir . 'extention.inc.php'); if (!defined('INSTALL_MODULE')) { $file = PC_PATH . 'languages' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'lang') . DIRECTORY_SEPARATOR . 'system_menu.lang.php'; if (file_exists($file)) { $content = file_get_contents($file); $content = substr($content, 0, -2); $data = ''; foreach ($language as $key => $l) { if (L($key, '', 'system_menu') == L('no_language') . '[' . $key . ']') { $data .= "\$LANG['" . $key . "'] = '" . $l . "';\r\n"; } } $data = $content . $data . "?>"; file_put_contents($file, $data); } else { foreach ($language as $key => $l) { if (L($key, '', 'system_menu') == L('no_language') . '[' . $key . ']') { $data .= "\$LANG['" . $key . "'] = '" . $l . "';\r\n"; } } $data = "<?" . "php\r\n\$data?>"; file_put_contents($file, $data); } } } if (!defined('INSTALL_MODULE')) { if (file_exists($this->installdir . 'languages' . DIRECTORY_SEPARATOR)) { dir_copy($this->installdir . 'languages' . DIRECTORY_SEPARATOR, PC_PATH . 'languages' . DIRECTORY_SEPARATOR); } if (file_exists($this->installdir . 'templates' . DIRECTORY_SEPARATOR)) { dir_copy($this->installdir . 'templates' . DIRECTORY_SEPARATOR, PC_PATH . 'templates' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'tpl_name') . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR); if (file_exists($this->installdir . 'templates' . DIRECTORY_SEPARATOR . 'name.inc.php')) { $keyid = 'templates|' . pc_base::load_config('system', 'tpl_name') . '|' . $this->module; $file_explan[$keyid] = (include $this->installdir . 'templates' . DIRECTORY_SEPARATOR . 'name.inc.php'); $templatepath = PC_PATH . 'templates' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'tpl_name') . DIRECTORY_SEPARATOR; if (file_exists($templatepath . 'config.php')) { $style_info = (include $templatepath . 'config.php'); $style_info['file_explan'] = array_merge($style_info['file_explan'], $file_explan); @file_put_contents($templatepath . 'config.php', '<?php return ' . var_export($style_info, true) . ';?>'); } unlink(PC_PATH . 'templates' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'tpl_name') . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR . 'name.inc.php'); } } } return true; }
/** * Copy all the content of a directory * * @param string $s source directory * @param string $d destination directory */ function dir_copy($source, $dest) { if (is_file($source)) { copy($source, $dest); chmod($dest, fileperms($source)); } else { mkdir($dest, 0777); if ($l = dir_scan($source)) { foreach ($l as $f) { dir_copy("{$source}/{$f}", "{$dest}/{$f}"); } } } }