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


PHP getcwd函数代码示例

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


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

示例1: __construct

 function __construct(array $config = array())
 {
     $this->_config =& $config;
     // Try to locate app folder.
     if (!isset($config['app_dir'])) {
         $cwd = getcwd();
         while (!is_dir("{$cwd}/app")) {
             if ($cwd == dirname($cwd)) {
                 throw new \LogicException('/app folder not found.');
             }
             $cwd = dirname($cwd);
         }
         $config['app_dir'] = "{$cwd}/app";
     }
     $is_web_request = isset($_SERVER['SERVER_NAME']);
     $config += array('debug' => !$is_web_request || $_SERVER['SERVER_NAME'] == 'localhost', 'register_exception_handler' => $is_web_request, 'register_error_handler' => $is_web_request, 'core_dir' => __DIR__ . '/../..', 'data_dir' => "{$config['app_dir']}/../data");
     $this->exception_handler = new ExceptionHandler($this->debug);
     if ($this->register_exception_handler) {
         set_exception_handler(array($this->exception_handler, 'handle'));
     }
     if ($this->register_error_handler) {
         $this->errorHandler = \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
     }
     foreach (array($config['data_dir'], "{$config['data_dir']}/cache", "{$config['data_dir']}/logs") as $dir) {
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
 }
开发者ID:z7,项目名称:hydra,代码行数:29,代码来源:Core.php

示例2: archive

 public static function archive($name = false, $listFilesAndFolders, $export_files_dir, $export_files_dir_name, $backupName, $move = false, $identifier, $type)
 {
     if (empty($export_files_dir)) {
         return;
     }
     $dir_separator = DIRECTORY_SEPARATOR;
     $backupName = 'backup' . $dir_separator . $backupName;
     $installFilePath = 'system' . $dir_separator . 'admin-scripts' . $dir_separator . 'miscellaneous' . $dir_separator;
     $dbSQLFilePath = 'backup' . $dir_separator;
     $old_path = getcwd();
     chdir($export_files_dir);
     $tar = new Archive_Tar($backupName, 'gz');
     if (SJB_System::getIfTrialModeIsOn()) {
         $tar->setIgnoreList(array('system/plugins/mobile', 'system/plugins/facebook_app', 'templates/mobile', 'templates/Facebook'));
     }
     SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
     switch ($type) {
         case 'full':
             $tar->addModify("{$installFilePath}install.php", '', $installFilePath);
             $tar->addModify($dbSQLFilePath . $name, '', $dbSQLFilePath);
             $tar->addModify($listFilesAndFolders, '');
             SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $name);
             break;
         case 'files':
             $tar->addModify("{$installFilePath}install.php", '', $installFilePath);
             $tar->addModify($listFilesAndFolders, '');
             break;
         case 'database':
             $tar->addModify($dbSQLFilePath . $listFilesAndFolders, '', $dbSQLFilePath);
             SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $listFilesAndFolders);
             break;
     }
     chdir($old_path);
     return true;
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:35,代码来源:Backup.php

示例3: execute

 public function execute()
 {
     global $wgUser;
     # Change to current working directory
     $oldCwd = getcwd();
     chdir($oldCwd);
     # Options processing
     $user = $this->getOption('u', 'Delete page script');
     $reason = $this->getOption('r', '');
     $interval = $this->getOption('i', 0);
     if ($this->hasArg()) {
         $file = fopen($this->getArg(), 'r');
     } else {
         $file = $this->getStdin();
     }
     # Setup
     if (!$file) {
         $this->error("Unable to read file, exiting", true);
     }
     $wgUser = User::newFromName($user);
     $dbw = wfGetDB(DB_MASTER);
     # Handle each entry
     for ($linenum = 1; !feof($file); $linenum++) {
         $line = trim(fgets($file));
         if ($line == '') {
             continue;
         }
         $page = Title::newFromText($line);
         if (is_null($page)) {
             $this->output("Invalid title '{$line}' on line {$linenum}\n");
             continue;
         }
         if (!$page->exists()) {
             $this->output("Skipping nonexistent page '{$line}'\n");
             continue;
         }
         $this->output($page->getPrefixedText());
         $dbw->begin();
         if ($page->getNamespace() == NS_FILE) {
             $art = new ImagePage($page);
             $img = wfFindFile($art->mTitle);
             if (!$img || !$img->isLocal() || !$img->delete($reason)) {
                 $this->output(" FAILED to delete image file... ");
             }
         } else {
             $art = new Article($page);
         }
         $success = $art->doDeleteArticle($reason);
         $dbw->commit();
         if ($success) {
             $this->output(" Deleted!\n");
         } else {
             $this->output(" FAILED to delete article\n");
         }
         if ($interval) {
             sleep($interval);
         }
         wfWaitForSlaves();
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:60,代码来源:deleteBatch.php

示例4: suggest_university

 function suggest_university()
 {
     if (!$this->tank_auth->is_admin_logged_in()) {
         redirect('admin/adminlogin/');
     } else {
         $data = $this->path->all_path();
         $data['user_id'] = $this->tank_auth->get_admin_user_id();
         $data['admin_user_level'] = $this->tank_auth->get_admin_user_level();
         $data['admin_priv'] = $this->adminmodel->get_user_privilege($data['user_id']);
         if (!$data['admin_priv']) {
             redirect('admin/adminlogout');
         }
         $hint = strtolower($_GET["q"]);
         if (!$hint) {
             return;
         }
         $data['univ_info'] = $this->autosuggest_model->get_univ_detail($hint);
         if ($data['univ_info'] != 0) {
             foreach ($data['univ_info'] as $univ_info) {
                 $univ_name = $univ_info->univ_name;
                 $univ_id = $univ_info->univ_id;
                 if (file_exists(getcwd() . '/uploads/univ_gallery/' . $univ_info->univ_logo_path) && $univ_info->univ_logo_path != '') {
                     $img_name = $univ_info->univ_logo_path;
                 } else {
                     $img_name = 'logo.png';
                 }
                 $img = '<img src="' . base_url() . '/uploads/univ_gallery/' . $img_name . '" style="width:50px;height:25px;">';
                 echo $img . '<b>' . "{$univ_name}|{$univ_id}\n";
             }
         } else {
             echo 'No Result Found';
         }
     }
 }
开发者ID:flyeven,项目名称:Meet-Univ,代码行数:34,代码来源:autosuggest.php

示例5: react

 private function react($type, $fqcn, $variables)
 {
     $className = $this->getClassName($fqcn);
     $nameSpace = $this->getNameSpace($fqcn);
     $variablesArray = array();
     foreach ($variables as $variableString) {
         $parts = explode(':', $variableString);
         $variablesArray[$parts[1]] = $parts[0];
     }
     switch ($type) {
         case 'dto':
             $generator = new DTO($className, $nameSpace, $variablesArray);
             break;
         case 'dto-unit':
             $generator = new DTOUnit($className, $nameSpace, $variablesArray);
             $className .= 'Test';
             break;
         default:
             throw new \RuntimeException('A formula for that reaction is not found!');
     }
     $directory = getcwd() . '/' . $this->getPath($fqcn);
     if (is_dir($directory) && !is_writable($directory)) {
         $output->writeln(sprintf('The "%s" directory is not writable', $directory));
         return;
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     file_put_contents($directory . '/' . $className . '.php', $generator->generate());
     return "Done!";
 }
开发者ID:jrobertfox,项目名称:dtox,代码行数:31,代码来源:DtoxCommand.php

示例6: createDeployer

 /** @return Deployer */
 private function createDeployer($config)
 {
     $config = array_change_key_case($config, CASE_LOWER) + ['local' => '', 'passivemode' => TRUE, 'ignore' => '', 'allowdelete' => TRUE, 'purge' => '', 'before' => '', 'after' => '', 'preprocess' => TRUE];
     if (empty($config['remote']) || !parse_url($config['remote'])) {
         throw new \Exception("Missing or invalid 'remote' URL in config.");
     }
     $server = parse_url($config['remote'], PHP_URL_SCHEME) === 'sftp' ? new SshServer($config['remote']) : new FtpServer($config['remote'], (bool) $config['passivemode']);
     if (!preg_match('#/|\\\\|[a-z]:#iA', $config['local'])) {
         if ($config['local'] && getcwd() !== dirname($this->configFile)) {
             $this->logger->log('WARNING: the "local" path is now relative to the directory where ' . basename($this->configFile) . ' is placed', 'red');
         }
         $config['local'] = dirname($this->configFile) . '/' . $config['local'];
     }
     $deployment = new Deployer($server, $config['local'], $this->logger);
     if ($config['preprocess']) {
         $deployment->preprocessMasks = $config['preprocess'] == 1 ? ['*.js', '*.css'] : self::toArray($config['preprocess']);
         // intentionally ==
         $preprocessor = new Preprocessor($this->logger);
         $deployment->addFilter('js', [$preprocessor, 'expandApacheImports']);
         $deployment->addFilter('js', [$preprocessor, 'compressJs'], TRUE);
         $deployment->addFilter('css', [$preprocessor, 'expandApacheImports']);
         $deployment->addFilter('css', [$preprocessor, 'expandCssImports']);
         $deployment->addFilter('css', [$preprocessor, 'compressCss'], TRUE);
     }
     $deployment->ignoreMasks = array_merge(['*.bak', '.svn', '.git*', 'Thumbs.db', '.DS_Store'], self::toArray($config['ignore']));
     $deployment->deploymentFile = empty($config['deploymentfile']) ? $deployment->deploymentFile : $config['deploymentfile'];
     $deployment->allowDelete = $config['allowdelete'];
     $deployment->toPurge = self::toArray($config['purge'], TRUE);
     $deployment->runBefore = self::toArray($config['before'], TRUE);
     $deployment->runAfter = self::toArray($config['after'], TRUE);
     $deployment->testMode = !empty($config['test']) || $this->mode === 'test';
     return $deployment;
 }
开发者ID:dsmaga,项目名称:ftp-deployment,代码行数:34,代码来源:CliRunner.php

示例7: execute

 /**
  * Executes Composer and runs a specified command (e.g. install / update)
  */
 public function execute()
 {
     $path = $this->phpci->buildPath;
     $build = $this->build;
     if ($this->directory == $path) {
         return false;
     }
     $filename = str_replace('%build.commit%', $build->getCommitId(), $this->filename);
     $filename = str_replace('%build.id%', $build->getId(), $filename);
     $filename = str_replace('%build.branch%', $build->getBranch(), $filename);
     $filename = str_replace('%project.title%', $build->getProject()->getTitle(), $filename);
     $filename = str_replace('%date%', date('Y-m-d'), $filename);
     $filename = str_replace('%time%', date('Hi'), $filename);
     $filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     if (!is_array($this->format)) {
         $this->format = array($this->format);
     }
     foreach ($this->format as $format) {
         switch ($format) {
             case 'tar':
                 $cmd = 'tar cfz "%s/%s.tar.gz" ./*';
                 break;
             default:
             case 'zip':
                 $cmd = 'zip -rq "%s/%s.zip" ./*';
                 break;
         }
         $success = $this->phpci->executeCommand($cmd, $this->directory, $filename);
     }
     chdir($curdir);
     return $success;
 }
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:37,代码来源:PackageBuild.php

示例8: testGetoleData

 public function testGetoleData()
 {
     $index = 0;
     $renderFormat = "png";
     $result = $this->object->getoleData($index, $renderFormat);
     $this->assertFileExists(getcwd() . '/Data/Output/DrawingObject_' . $index . '.' . $renderFormat);
 }
开发者ID:jasonpranevicius,项目名称:Aspose_Cloud_SDK_For_PHP,代码行数:7,代码来源:ExtractorTest.php

示例9: configure

 /**
  * Configure the command options.
  *
  * @return void
  */
 protected function configure()
 {
     $this->basePath = getcwd();
     $this->projectName = basename(getcwd());
     $this->defaultName = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $this->projectName)));
     $this->setName('make')->setDescription('Install Fourstead into the current project')->addOption('name', null, InputOption::VALUE_OPTIONAL, 'The name of the virtual machine.', $this->defaultName)->addOption('hostname', null, InputOption::VALUE_OPTIONAL, 'The hostname of the virtual machine.', $this->defaultName)->addOption('ip', null, InputOption::VALUE_OPTIONAL, 'The IP address of the virtual machine.')->addOption('after', null, InputOption::VALUE_NONE, 'Determines if the after.sh file is created.')->addOption('aliases', null, InputOption::VALUE_NONE, 'Determines if the aliases file is created.')->addOption('example', null, InputOption::VALUE_NONE, 'Determines if a Fourstead.yaml.example file is created.');
 }
开发者ID:itdc,项目名称:fourstead,代码行数:12,代码来源:MakeCommand.php

示例10: __construct

 public function __construct()
 {
     parent::__construct();
     $this->addArgument('gateway', 'Create IPN messages for which gateway', true);
     $this->addOption('max-messages', 'At most create <n> messages', 10, 'm');
     $this->addOption('output-dir', 'Write messages to this directory', getcwd(), 'o');
 }
开发者ID:wikimedia,项目名称:wikimedia-fundraising-crm-vendor,代码行数:7,代码来源:CreateIpnMessagesFromPendingDb.php

示例11: execute

 /**
  * Execute the command.
  *
  * @param Input $input
  * @param Output $output
  * @return void
  */
 protected function execute(Input $input, Output $output)
 {
     $name = $input->getArgument("name");
     // Validate the name straight away.
     if (count($chunks = explode("/", $name)) != 2) {
         throw new \InvalidArgumentException("Invalid repository name '{$name}'.");
     }
     $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks)));
     // If we're in a test environment, stop executing.
     if (defined("ADVISER_UNDER_TEST")) {
         return null;
     }
     // @codeCoverageIgnoreStart
     if (!$this->git->cloneGithubRepository($name)) {
         throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist.");
     }
     // Change the working directory.
     chdir($path = getcwd() . "/" . end($chunks));
     $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path));
     $output->writeln("");
     // Running "AnalyseCommand"...
     $arrayInput = [""];
     if (!is_null($input->getOption("formatter"))) {
         $arrayInput["--formatter"] = $input->getOption("formatter");
     }
     $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output);
     // Change back, remove the directory.
     chdir(getcwd() . "/..");
     $this->removeDirectory($path);
     $output->writeln("");
     $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path));
     // @codeCoverageIgnoreStop
 }
开发者ID:bound1ess,项目名称:adviser,代码行数:40,代码来源:AnalyseRepositoryCommand.php

示例12: setting_manager

 function setting_manager($post = false)
 {
     $this->sanitizer =& TextSanitizer::getInstance();
     if ($post) {
         $this->readPost();
     } else {
         $this->database = 'mysql';
         $this->dbhost = 'localhost';
         $this->prefix = 'xoops';
         $this->db_pconnect = 0;
         $this->root_path = str_replace("\\", "/", getcwd());
         // "
         $this->root_path = str_replace("/install", "", $this->root_path);
         $filepath = !empty($_SERVER['REQUEST_URI']) ? dirname($_SERVER['REQUEST_URI']) : dirname($_SERVER['SCRIPT_NAME']);
         $filepath = str_replace("\\", "/", $filepath);
         // "
         $filepath = str_replace("/install", "", $filepath);
         if (substr($filepath, 0, 1) == "/") {
             $filepath = substr($filepath, 1);
         }
         if (substr($filepath, -1) == "/") {
             $filepath = substr($filepath, 0, -1);
         }
         $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
         $this->xoops_url = !empty($filepath) ? $protocol . $_SERVER['HTTP_HOST'] . "/" . $filepath : $protocol . $_SERVER['HTTP_HOST'];
     }
 }
开发者ID:BackupTheBerlios,项目名称:xoops4-svn,代码行数:27,代码来源:settingmanager.php

示例13: testDot

 function testDot()
 {
     $dir = new WatchmanDirectoryFixture();
     $root = $dir->getPath();
     try {
         $this->assertEqual(true, chdir($root), "failed to chdir {$root}");
         $this->assertEqual($root, getcwd(), "chdir/getcwd are consistent");
         $is_cli = $this->isUsingCLI();
         if (phutil_is_windows()) {
             $dot = '';
             $err = 'unable to resolve root : path "" must be absolute';
         } else {
             $dot = '.';
             $err = 'unable to resolve root .: path "." must be absolute';
         }
         $res = $this->watch($dot, false);
         if (!$this->isUsingCLI()) {
             $this->assertEqual($err, idx($res, 'error'));
         } else {
             $this->assertEqual(null, idx($res, 'error'));
             $this->assertEqual($root, idx($res, 'watch'));
         }
     } catch (Exception $e) {
         chdir($this->getRoot());
         throw $e;
     }
 }
开发者ID:xihaxiaozi1,项目名称:watchman,代码行数:27,代码来源:absroot.php

示例14: url2fullPath

 /** Resolve full filesystem path of given URL. Returns FALSE if the URL
  * cannot be resolved
  * @param string $url
  * @return string */
 static function url2fullPath($url)
 {
     $url = self::normalize($url);
     $uri = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : false);
     $uri = self::normalize($uri);
     if (substr($url, 0, 1) !== "/") {
         if ($uri === false) {
             return false;
         }
         $url = dirname($uri) . "/{$url}";
     }
     if (isset($_SERVER['DOCUMENT_ROOT'])) {
         return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/{$url}");
     } else {
         if ($uri === false) {
             return false;
         }
         if (isset($_SERVER['SCRIPT_FILENAME'])) {
             $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']);
             return self::normalize(substr($scr_filename, 0, -strlen($uri)) . "/{$url}");
         }
         $count = count(explode('/', $uri)) - 1;
         for ($i = 0, $chdir = ""; $i < $count; $i++) {
             $chdir .= "../";
         }
         $chdir = self::normalize($chdir);
         $dir = getcwd();
         if ($dir === false || !@chdir($chdir)) {
             return false;
         }
         $rdir = getcwd();
         chdir($dir);
         return $rdir !== false ? self::normalize($rdir . "/{$url}") : false;
     }
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:39,代码来源:helper_path.php

示例15: LandFAAS

 function LandFAAS($http_post_vars, $afsID = "", $propertyID = "", $formAction = "", $sess)
 {
     $this->sess = $sess;
     $this->tpl = new rpts_Template(getcwd(), "keep");
     $this->tpl->set_file("rptsTemplate", "LandFAAS.htm");
     $this->tpl->set_var("TITLE", "Encode Land");
     $this->formArray = array("afsID" => $afsID, "propertyID" => $propertyID, "arpNumber" => "", "propertyIndexNumber" => "", "propertyAdministrator" => "", "personID" => "", "lastName" => "", "firstName" => "", "middleName" => "", "gender" => "", "birth_month" => date("n"), "birth_day" => date("j"), "birth_year" => date("Y"), "maritalStatus" => "", "tin" => "", "addressID" => "", "number" => "", "street" => "", "barangay" => "", "district" => "", "municipalityCity" => "", "province" => "", "telephone" => "", "mobileNumber" => "", "email" => "", "verifiedByID" => "", "verifiedBy" => "", "verifiedByName" => "", "plottingsByID" => "", "plottingsBy" => "", "plottingsByName" => "", "notedByID" => "", "notedBy" => "", "notedByName" => "", "marketValue" => "", "kind" => "", "actualUse" => "", "adjustedMarketValue" => "", "assessmentLevel" => "", "assessedValue" => "", "previousOwner" => "", "previousAssessedValue" => "", "taxability" => "", "effectivity" => "", "appraisedByID" => "", "appraisedBy" => "", "appraisedByName" => "", "appraisedByDate" => "", "recommendingApprovalID" => "", "recommendingApproval" => "", "recommendingApprovalName" => "", "recommendingApprovalDate" => "", "approvedByID" => "", "approvedBy" => "", "approvedByName" => "", "approvedByDate" => "", "memoranda" => "", "postingDate" => "", "octTctNumber" => "", "surveyNumber" => "", "north" => "", "east" => "", "south" => "", "west" => "", "classification" => "", "subClass" => "", "area" => "", "unitValue" => "", "adjustmentFactor" => "", "percentAdjustment" => "", "valueAdjustment" => "", "as_month" => date("n"), "as_day" => date("j"), "as_year" => date("Y"), "re_month" => date("n"), "re_day" => date("j"), "re_year" => date("Y"), "av_month" => date("n"), "av_day" => date("j"), "av_year" => date("Y"), "formAction" => $formAction);
     foreach ($http_post_vars as $key => $value) {
         $this->formArray[$key] = $value;
         //echo $key." = ".$this->formArray[$key]."<br>";
     }
     $as_dateStr = $this->formArray["as_year"] . "-" . putPreZero($this->formArray["as_month"]) . "-" . putPreZero($this->formArray["as_day"]);
     $this->formArray["appraisedByDate"] = $as_dateStr;
     $re_dateStr = $this->formArray["re_year"] . "-" . putPreZero($this->formArray["re_month"]) . "-" . putPreZero($this->formArray["re_day"]);
     $this->formArray["recommendingApprovalDate"] = $re_dateStr;
     $av_dateStr = $this->formArray["av_year"] . "-" . putPreZero($this->formArray["av_month"]) . "-" . putPreZero($this->formArray["av_day"]);
     $this->formArray["approvedByDate"] = $av_dateStr;
     $AssessorList = new SoapObject(NCCBIZ . "AssessorList.php", "urn:Object");
     if (!($xmlStr = $AssessorList->getAssessorList())) {
         $this->tpl->set_block("rptsTemplate", "Dropdown", "DropdownBlock");
         $this->tpl->set_var("DropdownBlock", "page not found");
     } else {
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             $this->tpl->set_block("rptsTemplate", "Dropdown", "DropdownBlock");
             $this->tpl->set_var("DropdownBlock", "error xmlDoc");
         } else {
             $assessorRecords = new AssessorRecords();
             $assessorRecords->parseDomDocument($domDoc);
             $this->assessorList = $assessorRecords->getArrayList();
         }
     }
 }
开发者ID:armic,项目名称:erpts,代码行数:32,代码来源:LandFAAS.php


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