本文整理汇总了PHP中file_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP file_exists函数的具体用法?PHP file_exists怎么用?PHP file_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getArgument('path');
if (!file_exists($path)) {
$output->writeln("{$path} is not a file or a path");
}
$filePaths = [];
if (is_file($path)) {
$filePaths = [realpath($path)];
} elseif (is_dir($path)) {
$filePaths = array_diff(scandir($path), array('..', '.'));
} else {
$output->writeln("{$path} is not known.");
}
$generator = new StopwordGenerator($filePaths);
if ($input->getArgument('type') === 'json') {
echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
echo json_last_error_msg();
die;
$output->write(json_encode($this->toArray($generator->getStopwords())));
} else {
$stopwords = $generator->getStopwords();
$stdout = fopen('php://stdout', 'w');
echo 'token,freq' . PHP_EOL;
foreach ($stopwords as $token => $freq) {
fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
}
fclose($stdout);
}
}
开发者ID:yooper,项目名称:php-text-analysis,代码行数:30,代码来源:StopWordsCommand.php
示例2: prepare_dir
public static function prepare_dir($prefix)
{
$config = midcom_baseclasses_components_configuration::get('midcom.helper.filesync', 'config');
$path = $config->get('filesync_path');
if (!file_exists($path)) {
$parent = dirname($path);
if (!is_writable($parent)) {
throw new midcom_error("Directory {$parent} is not writable");
}
if (!mkdir($path)) {
throw new midcom_error("Failed to create directory {$path}. Reason: " . $php_errormsg);
}
}
if (substr($path, -1) != '/') {
$path .= '/';
}
$module_dir = "{$path}{$prefix}";
if (!file_exists($module_dir)) {
if (!is_writable($path)) {
throw new midcom_error("Directory {$path} is not writable");
}
if (!mkdir($module_dir)) {
throw new midcom_error("Failed to create directory {$module_dir}. Reason: " . $php_errormsg);
}
}
return "{$module_dir}/";
}
开发者ID:nemein,项目名称:openpsa,代码行数:27,代码来源:interfaces.php
示例3: template
/**
* Compiles a template and writes it to a cache file, which is used for inclusion.
*
* @param string $file The full path to the template that will be compiled.
* @param array $options Options for compilation include:
* - `path`: Path where the compiled template should be written.
* - `fallback`: Boolean indicating that if the compilation failed for some
* reason (e.g. `path` is not writable), that the compiled template
* should still be returned and no exception be thrown.
* @return string The compiled template.
*/
public static function template($file, array $options = array())
{
$cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
$defaults = array('path' => $cachePath, 'fallback' => false);
$options += $defaults;
$stats = stat($file);
$oname = basename(dirname($file)) . '_' . basename($file, '.php');
$oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
$template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
$template = "{$options['path']}/{$template}";
if (file_exists($template)) {
return $template;
}
$compiled = static::compile(file_get_contents($file));
if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
if ($expired !== $template) {
unlink($expired);
}
}
return $template;
}
if ($options['fallback']) {
return $file;
}
throw new TemplateException("Could not write compiled template `{$template}` to cache.");
}
开发者ID:fedeisas,项目名称:lithium,代码行数:38,代码来源:Compiler.php
示例4: getPoint
/**
* @brief Get the points
*/
function getPoint($member_srl, $from_db = false)
{
$member_srl = abs($member_srl);
// Get from instance memory
if (!$from_db && $this->pointList[$member_srl]) {
return $this->pointList[$member_srl];
}
// Get from file cache
$path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
if (!$from_db && file_exists($cache_filename)) {
return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
}
// Get from the DB
$args = new stdClass();
$args->member_srl = $member_srl;
$output = executeQuery('point.getPoint', $args);
if (isset($output->data->member_srl)) {
$point = (int) $output->data->point;
$this->pointList[$member_srl] = $point;
if (!is_dir($path)) {
FileHandler::makeDir($path);
}
FileHandler::writeFile($cache_filename, $point);
return $point;
}
return 0;
}
开发者ID:kimkucheol,项目名称:xe-core,代码行数:31,代码来源:point.model.php
示例5: addFieldToModule
public function addFieldToModule($field)
{
global $log;
$fileName = 'modules/Settings/Vtiger/models/CompanyDetails.php';
$fileExists = file_exists($fileName);
if ($fileExists) {
require_once $fileName;
$fileContent = file_get_contents($fileName);
$placeToAdd = "'website' => 'text',";
$newField = "'{$field}' => 'text',";
if (self::parse_data($placeToAdd, $fileContent)) {
$fileContent = str_replace($placeToAdd, $placeToAdd . PHP_EOL . ' ' . $newField, $fileContent);
} else {
if (self::parse_data('?>', $fileContent)) {
$fileContent = str_replace('?>', '', $fileContent);
}
$fileContent = $fileContent . PHP_EOL . $placeToAdd . PHP_EOL . ' ' . $newField . PHP_EOL . ');';
}
$log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - add line to modules/Settings/Vtiger/models/CompanyDetails.php ');
} else {
$log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - File does not exist');
return FALSE;
}
$filePointer = fopen($fileName, 'w');
fwrite($filePointer, $fileContent);
fclose($filePointer);
return TRUE;
}
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:28,代码来源:SaveCompanyField.php
示例6: getAvailablePackages
/**
* Returns all available packages.
*
* @param bool $filterInstalled True to only return installed packages
*
* @return Package[]
*/
public function getAvailablePackages($filterInstalled = true)
{
$dh = $this->application->make('helper/file');
$packages = $dh->getDirectoryContents(DIR_PACKAGES);
if ($filterInstalled) {
$handles = self::getInstalledHandles();
// strip out packages we've already installed
$packagesTemp = array();
foreach ($packages as $p) {
if (!in_array($p, $handles)) {
$packagesTemp[] = $p;
}
}
$packages = $packagesTemp;
}
if (count($packages) > 0) {
$packagesTemp = array();
// get package objects from the file system
foreach ($packages as $p) {
if (file_exists(DIR_PACKAGES . '/' . $p . '/' . FILENAME_CONTROLLER)) {
$pkg = $this->getClass($p);
if (!empty($pkg)) {
$packagesTemp[] = $pkg;
}
}
}
$packages = $packagesTemp;
}
return $packages;
}
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:37,代码来源:PackageService.php
示例7: indexAction
public function indexAction()
{
$container = $this->container;
$conn = $this->get('doctrine')->getConnection();
$dir = $container->getParameter('doctrine_migrations.dir_name');
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
$configuration = new Configuration($conn);
$configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
$configuration->setMigrationsDirectory($dir);
$configuration->registerMigrationsFromDirectory($dir);
$configuration->setName($container->getParameter('doctrine_migrations.name'));
$configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
$versions = $configuration->getMigrations();
foreach ($versions as $version) {
$migration = $version->getMigration();
if ($migration instanceof ContainerAwareInterface) {
$migration->setContainer($container);
}
}
$migration = new Migration($configuration);
$migrated = $migration->migrate();
// ...
}
开发者ID:ssone,项目名称:cms-bundle,代码行数:25,代码来源:MigrationController.php
示例8: CheckServer
/**
* Installer::CheckServer()
*
* @return
*/
public static function CheckServer()
{
$noerror = true;
$version = phpversion();
$wf = array();
// These needa be writable
$wf[] = 'core/cache';
$wf[] = 'core/logs';
$wf[] = 'core/pages';
$wf[] = 'lib/avatars';
$wf[] = 'lib/rss';
$wf[] = 'lib/signatures';
// Check the PHP version
if ($version[0] != '5') {
$noerror = false;
$type = 'error';
$message = 'You need PHP 5 (your version: ' . $version . ')';
} else {
$type = 'success';
$message = 'OK! (your version:' . $version . ')';
}
Template::Set('phpversion', '<div id="' . $type . '">' . $message . '</div>');
// Check if core/site_config.inc.php is writeable
if (!file_exists(CORE_PATH . '/local.config.php')) {
if (!($fp = fopen(CORE_PATH . '/local.config.php', 'w'))) {
$noerror = false;
$type = 'error';
$message = 'Could not create core/local.config.php. Create this file, blank, with write permissions.';
} else {
$type = 'success';
$message = 'core/local.config.php is writeable!';
}
} else {
if (!is_writeable(CORE_PATH . '/local.config.php')) {
$noerror = false;
$type = 'error';
$message = 'core/local.config.php is not writeable';
} else {
$type = 'success';
$message = 'core/local.config.php is writeable!';
}
}
Template::Set('configfile', '<div id="' . $type . '">' . $message . '</div>');
// Check all of the folders for writable permissions
$status = '';
foreach ($wf as $folder) {
if (!is_writeable(SITE_ROOT . '/' . $folder)) {
$noerror = false;
$type = 'error';
$message = $folder . ' is not writeable';
} else {
$type = 'success';
$message = $folder . ' is writeable!';
}
$status .= '<div id="' . $type . '">' . $message . '</div>';
}
Template::Set('directories', $status);
//Template::Set('pagesdir', '<div id="'.$type.'">'.$message.'</div>');
return $noerror;
}
开发者ID:Galihom,项目名称:phpVMS,代码行数:65,代码来源:Installer.class.php
示例9: getApertureFields
/**
* Load metadata about an HTML document using Aperture.
*
* @param string $htmlFile File on disk containing HTML.
*
* @return array
*/
protected static function getApertureFields($htmlFile)
{
$xmlFile = tempnam('/tmp', 'apt');
$cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler');
exec($cmd);
// If we failed to process the file, give up now:
if (!file_exists($xmlFile)) {
throw new \Exception('Aperture failed.');
}
// Extract and decode the full text from the XML:
$xml = str_replace(chr(0), ' ', file_get_contents($xmlFile));
@unlink($xmlFile);
preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches);
$final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Extract the title from the XML:
preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches);
$title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Extract the keywords from the XML:
preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches);
$keywords = [];
if (isset($matches[1])) {
foreach ($matches[1] as $current) {
$keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8'));
}
}
// Extract the description from the XML:
preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches);
$description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Send back the extracted fields:
return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final];
}
开发者ID:grharry,项目名称:vufind,代码行数:38,代码来源:VuFindSitemap.php
示例10: makeSure
/**
* Make sure if user want to replace existing class.
*
* @param string $path
* @param bool $force
*/
protected function makeSure($path, $force)
{
if ($force === false and file_exists($path) and $this->confirm('File already exists, do you want to replace? [y|N]') === false) {
$this->warn('==> Cannot generate command because destination file already exists.');
die(1);
}
}
开发者ID:krisanalfa,项目名称:konsole,代码行数:13,代码来源:GenerateCommand.php
示例11: load
function load($tpl_view, $body_view = null, $data = null)
{
if (!is_null($body_view)) {
if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view)) {
$body_view_path = $tpl_view . '/' . $body_view;
} else {
if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view . '.php')) {
$body_view_path = $tpl_view . '/' . $body_view . '.php';
} else {
if (file_exists(APPPATH . 'views/' . $body_view)) {
$body_view_path = $body_view;
} else {
if (file_exists(APPPATH . 'views/' . $body_view . '.php')) {
$body_view_path = $body_view . '.php';
} else {
show_error('Unable to load the requested file: ' . $tpl_name . '/' . $view_name . '.php');
}
}
}
}
$body = $this->ci->load->view($body_view_path, $data, TRUE);
if (is_null($data)) {
$data = array('body' => $body);
} else {
if (is_array($data)) {
$data['body'] = $body;
} else {
if (is_object($data)) {
$data->body = $body;
}
}
}
}
$this->ci->load->view('templates/' . $tpl_view, $data);
}
开发者ID:rccghmp,项目名称:efollowup,代码行数:35,代码来源:Template.php
示例12: get
public function get()
{
$id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit;
if ($data = $this->db->getby_id($id)) {
if (!($str = S('dbsource_' . $id))) {
if ($data['type'] == 1) {
// 自定义SQL调用
$get_db = Loader::model("get_model");
$sql = $data['data'] . (!empty($data['num']) ? " LIMIT {$data['num']}" : '');
$str = $get_db->query($sql);
} else {
$filepath = APPS_PATH . $data['application'] . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . $data['application'] . '_tag.php';
if (file_exists($filepath)) {
$yun_tag = Loader::lib($data['application'] . ':' . $data['application'] . '_tag');
if (!method_exists($yun_tag, $data['do'])) {
exit;
}
$sql = string2array($data['data']);
$sql['do'] = $data['do'];
$sql['limit'] = $data['num'];
unset($data['num']);
$str = $yun_tag->{$data}['do']($sql);
} else {
exit;
}
}
if ($data['cache']) {
S('tpl_data/dbsource_' . $id, $str, $data['cache']);
}
}
echo $this->_format($data['id'], $str, $data['dis_type']);
}
}
开发者ID:hubs,项目名称:yuncms,代码行数:33,代码来源:CallController.php
示例13: doAction
function doAction($action)
{
$id = $_POST['id'];
$mapFile = "map/" . $id . ".map";
$offlineFile = "map/offline/" . $id . ".js";
switch ($action) {
case "save":
if (!is_dir("map")) {
mkdir("map");
mkdir("map/offline");
}
file_put_contents($mapFile, $_POST['data']);
file_put_contents($offlineFile, "Map.level[" . $id . "] = " . $_POST['data']);
return $_POST['data'];
break;
case "load":
if (!empty($_POST['offlineMode'])) {
return file_get_contents($offlineFile);
}
if (file_exists($mapFile)) {
return file_get_contents($mapFile);
}
echo "Echo file not found: " . $mapFile;
ThrowNotFound();
break;
}
}
开发者ID:rlugojr,项目名称:MightyEngine,代码行数:27,代码来源:level.php
示例14: upload
/**
* Upload Image to Imgur
*
* @param string $image A binary file (path to file), base64 data, or a URL for an image. (up to 10MB)
* @param string $type Image type. Use Mechpave\ImgurClient\Model\ImageModel
* @param string $title The title of the image
* @param string $description The description of the image
* @param string $album The id of the album you want to add the image to. For anonymous albums, {album} should be the deletehash that is returned at creation.
* @param string $name The name of the file
* @throws \UnexpectedValueException
* @return ImageInterface
*/
public function upload($image, $type, $title = null, $description = null, $album = null, $name = null)
{
if ($type == ImageModel::TYPE_FILE) {
//check if file exists and get its contents
if (!file_exists($image)) {
throw new \UnexpectedValueException('Provided file does not exist');
}
$contents = file_get_contents($image);
if (!$contents) {
throw new \UnexpectedValueException('Could not get file contents');
}
$image = $contents;
}
$postData = ['image' => $image, 'type' => $type];
if ($title) {
$postData['title'] = $title;
}
if ($name) {
$postData['name'] = $name;
}
if ($description) {
$postData['description'] = $description;
}
if ($album) {
$postData['album'] = $album;
}
$response = $this->httpClient->post('image', $postData);
$image = $this->imageMapper->buildImage($response->getBody()['data']);
return $image;
}
开发者ID:mechpave,项目名称:imgur-client,代码行数:42,代码来源:Image.php
示例15: filter
/**
* Defined by Zend_Filter_Interface
*
* Decrypts the file $value with the defined settings
*
* @param string $value Full path of file to change
* @return string The filename which has been set, or false when there were errors
*/
public function filter($value)
{
if (!file_exists($value)) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '{$value}' not found");
}
if (!isset($this->_filename)) {
$this->_filename = $value;
}
if (file_exists($this->_filename) and !is_writable($this->_filename)) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable");
}
$content = file_get_contents($value);
if (!$content) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while reading file '{$value}'");
}
$decrypted = parent::filter($content);
$result = file_put_contents($this->_filename, $decrypted);
if (!$result) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'");
}
return $this->_filename;
}
开发者ID:ideager,项目名称:wecenter,代码行数:34,代码来源:Decrypt.php
示例16: check
/**
* Executes the check itselfs
*
* @return boolean
*/
public function check()
{
$this->isFound = file_exists($this->filename);
$this->isReadable = is_readable($this->filename);
$result = $this->isFound && $this->isReadable;
return $result;
}
开发者ID:sschuberth,项目名称:Gerrie,代码行数:12,代码来源:ConfigFileCheck.php
示例17: loadController
function loadController($class)
{
if (file_exists(CONTROLLERS_DIR . DS . strtolower($class) . '.php')) {
require_once CONTROLLERS_DIR . DS . strtolower($class) . '.php';
}
return;
}
开发者ID:raxbg,项目名称:Jedi-Framework,代码行数:7,代码来源:autoload.php
示例18: jieshao
/**
* 店铺介绍页面
*/
public function jieshao()
{
$id = $_GET['id'];
$M = new ForemanviewModel();
$info = $M->getforemaninfo($id);
if ($info) {
if (empty($info['logo']) || !file_exists("." . $info['logo'])) {
$info['logo'] = "/Public/web/images/nopic_193.jpg";
}
#获取代表作品
$M1 = new CaseModel();
$info[caseinfo] = $M1->getcase($info[zuopin]);
$this->assign("info", $info);
#获取 业主合影
$M2 = new HeyingModel();
$hylist = $M2->getheying($id);
#var_dump($hylist);
$this->assign("hylist", $hylist);
#施工工地
$M3 = new GongdiModel();
$sggdstr = $M3->getsggdstr($id);
$this->assign("sggdstr", $sggdstr);
$sggdlist = $M3->getsggdlist($id);
$this->assign("sggdlist", $sggdlist);
$this->assign("id", $id);
} else {
$this->error("该工长已经被禁止,请联系管理员开通.");
}
$this->display();
}
开发者ID:snowtl,项目名称:tanglang,代码行数:33,代码来源:ForemanAction.class.php
示例19: index
public function index()
{
$this->load->language('payment/authorizenet_aim');
$data['text_credit_card'] = $this->language->get('text_credit_card');
$data['text_wait'] = $this->language->get('text_wait');
$data['entry_cc_owner'] = $this->language->get('entry_cc_owner');
$data['entry_cc_number'] = $this->language->get('entry_cc_number');
$data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date');
$data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2');
$data['button_confirm'] = $this->language->get('button_confirm');
$data['months'] = array();
for ($i = 1; $i <= 12; $i++) {
$data['months'][] = array('text' => strftime('%B', mktime(0, 0, 0, $i, 1, 2000)), 'value' => sprintf('%02d', $i));
}
$today = getdate();
$data['year_expire'] = array();
for ($i = $today['year']; $i < $today['year'] + 11; $i++) {
$data['year_expire'][] = array('text' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)), 'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)));
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/authorizenet_aim.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/payment/authorizenet_aim.tpl', $data);
} else {
return $this->load->view('default/template/payment/authorizenet_aim.tpl', $data);
}
}
开发者ID:RobinSmit,项目名称:opencart,代码行数:25,代码来源:authorizenet_aim.php
示例20: __construct
public function __construct(EngineInterface $engine, $proxyPath = null)
{
$this->engine = $engine;
if (file_exists($proxyPath)) {
unlink($this->proxyPath);
}
}
开发者ID:aszone,项目名称:search-hacking,代码行数:7,代码来源:SearchHacking.php
注:本文中的file_exists函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论