本文整理汇总了PHP中touch函数的典型用法代码示例。如果您正苦于以下问题:PHP touch函数的具体用法?PHP touch怎么用?PHP touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了touch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeProjectDir
protected function makeProjectDir($srcDir = null, $logsDir = null, $cloverXmlPaths = null, $logsDirUnwritable = false, $jsonPathUnwritable = false)
{
if ($srcDir !== null && !is_dir($srcDir)) {
mkdir($srcDir, 0777, true);
}
if ($logsDir !== null && !is_dir($logsDir)) {
mkdir($logsDir, 0777, true);
}
if ($cloverXmlPaths !== null) {
if (is_array($cloverXmlPaths)) {
foreach ($cloverXmlPaths as $cloverXmlPath) {
touch($cloverXmlPath);
}
} else {
touch($cloverXmlPaths);
}
}
if ($logsDirUnwritable) {
if (file_exists($logsDir)) {
chmod($logsDir, 0577);
}
}
if ($jsonPathUnwritable) {
touch($this->jsonPath);
chmod($this->jsonPath, 0577);
}
}
示例2: setupLanguageFile
protected function setupLanguageFile($catalogue, $languageEntity)
{
$languageFile = __DIR__ . sprintf("/../Resources/translations/%s.%s.db", $catalogue, $languageEntity);
if (!file_exists($languageFile)) {
touch($languageFile);
}
}
示例3: testCheckTarget_TargetIsTooFresh
public function testCheckTarget_TargetIsTooFresh()
{
\touch($this->sourceFile);
\touch($this->targetFile, time() + 10);
$result = $this->getTplInst()->checkTarget();
$this->assertFalse($result);
}
示例4: purge_step
public function purge_step($old_state)
{
switch ($old_state) {
case '':
// Empty means nothing has run yet
global $phpbb_root_path;
$phpbb_store_path = $phpbb_root_path . 'store/';
$this->del_content_dir('d120de/banner/default/');
$this->del_content_dir('d120de/banner/event/');
$this->del_content_dir('d120de/banner/');
unlink($phpbb_store_path . 'd120de/index.htm');
//this fails if there are other folders than banner
$del_res = rmdir($phpbb_store_path . 'd120de/');
if ($del_res === false) {
//we faild create index.htm again
touch($phpbb_store_path . 'd120de/index.htm');
}
return 'del_content_dir';
break;
default:
// Run parent purge step method
return parent::purge_step($old_state);
break;
}
}
示例5: Get
function Get($rss_url, $rss_feed_id)
{
$output = '';
if (!isset($this->num_results)) {
$this->num_results = 5;
}
if (!isset($this->description)) {
$this->description = FALSE;
}
$result = $this->Parse($rss_url);
if ($result && $result['items_count'] == 0) {
return null;
} else {
if ($result) {
$output = "<ul class='rss_feed'>";
for ($i = 0; $i < min($this->num_results, $result['items_count']); $i++) {
$output .= "<li><a href='" . $result['items'][$i]['link'] . "' target='_new'>" . $result['items'][$i]['title'] . "</a>";
if ($this->description) {
$output .= "<br />" . $result['items'][$i]['description'];
}
$output .= "</li>\n";
}
$output .= "</ul>\n";
} elseif (file_exists($cache_file)) {
touch($cache_file);
} else {
//create an empty file
if ($f = @fopen($cache_file, 'w')) {
fclose($f);
}
}
}
return $output;
}
示例6: verify
/**
* Verifies dependencies.
* @param array
* @return bool
*/
private function verify($meta)
{
do {
if (!empty($meta[self::META_DELTA])) {
// meta[file] was added by readMetaAndLock()
if (filemtime($meta[self::FILE]) + $meta[self::META_DELTA] < time()) {
break;
}
touch($meta[self::FILE]);
} elseif (!empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < time()) {
break;
}
if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
break;
}
if (!empty($meta[self::META_ITEMS])) {
foreach ($meta[self::META_ITEMS] as $depFile => $time) {
$m = $this->readMetaAndLock($depFile, LOCK_SH);
if ($m[self::META_TIME] !== $time || $m && !$this->verify($m)) {
break 2;
}
}
}
return TRUE;
} while (FALSE);
$this->delete($meta[self::FILE], $meta[self::HANDLE]);
// meta[handle] & meta[file] was added by readMetaAndLock()
return FALSE;
}
示例7: create
/**
* Create user cache.
*
* @param string $user Twitter screen name
* @return bool If successful true
* @throws CacheException Any errors
*/
public function create($user)
{
try {
$path = config("cache.path") . "/{$user}";
$json_file = "{$path}/data.json";
if (!$this->exists($user)) {
mkdir($path);
}
if (!file_exists($json_file)) {
touch($json_file);
}
$response = $this->twistOAuth->get("users/show", ["id" => $user]);
$image_url = str_replace("_normal", "", $response->profile_image_url_https);
$info = new SplFileInfo($image_url);
$curl = new Curl();
$curl->setUserAgent(SaveTweet::APP_NAME . "/" . SaveTweet::APP_VERSION . " with PHP/" . PHP_VERSION);
$curl->download($image_url, "{$path}/icon.{$info->getExtension()}");
$curl->close();
$data = ["name" => $response->name, "screen_name" => $response->screen_name, "id" => $response->id_str, "icon" => config("cache.http_path") . "/{$response->id_str}/icon.{$info->getExtension()}", "org_icon" => $image_url, "update_at" => time()];
$json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
(new SplFileObject($json_file, "w"))->fwrite($json);
return true;
} catch (RuntimeException $e) {
$this->_catch($e);
}
}
示例8: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// If DB file doesn't exist create it
if (!Storage::exists(database_path('SPGProfileDB.sqlite'))) {
touch(database_path('SPGProfileDB.sqlite'));
}
Schema::connection($this->TargetDB)->create('pass_profiles', function (Blueprint $table) {
$table->increments('id');
$table->string('profile_name')->unique();
$table->boolean('number');
$table->char('numbers', 10);
$table->boolean('lower');
$table->char('lower_case', 25);
$table->boolean('upper');
$table->char('upper_case', 26);
$table->boolean('symbol');
$table->char('symbols', 21);
$table->boolean('special');
$table->char('specials', 11);
$table->smallInteger('length', false, true);
$table->smallInteger('count', false, true);
$table->float('entropy')->nullable();
$table->timestamps();
});
}
开发者ID:Dev1436,项目名称:laravel-securepassgen,代码行数:30,代码来源:2015_12_12_012546_create_pass_profiles_table.php
示例9: getStatusFileObject
/**
* @return \SplFileObject
*
* @throws \RuntimeException
*/
protected function getStatusFileObject()
{
if (!is_file($this->getStatusFile())) {
touch($this->getStatusFile());
}
return new \SplFileObject($this->getStatusFile(), 'r+');
}
示例10: cache_prune_folder
/**
* Cleanup a single cache folder
*
* @param string $cache_folder path to cache folder
* @param int $cache_max_age maximum age of cached items in seconds
* @param bool $force_prune force cache pruning even if not due according to schedule
*/
function cache_prune_folder($cache_folder, $cache_max_age, $force_prune = false, $simulate = false, $pattern = '*')
{
if (!preg_match('#/$#', $cache_folder)) {
$cache_folder .= '/';
}
$stamp = $cache_folder . 'cache_last_purge';
$cache_mtime = @filemtime($stamp);
// get time the cache was last purged (once a day)
// if cache was last purged a day or more ago
if ($force_prune || time() - $cache_mtime > $cache_max_age / 24) {
foreach (glob($cache_folder . $pattern, GLOB_NOSORT) as $file) {
// avoid hidden files and directories
if (is_file($file) & !preg_match("/^\\./", $file) && time() - filemtime($file) > $cache_max_age) {
if ($simulate) {
$files[] = $file;
} else {
@unlink($file);
}
// purge cache
}
}
if ($simulate) {
return $files;
}
@touch($stamp);
// mark purge as having occurred
return true;
}
return false;
}
示例11: setUp
/**
* Sets the path to test files
*
* @return void
*/
public function setUp()
{
$this->filesPath = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, uniqid('zfilter'));
mkdir($this->filesPath, 0775, true);
$this->sourceFile = $this->filesPath . DIRECTORY_SEPARATOR . 'testfile.png';
touch($this->sourceFile);
}
示例12: load
public function load($filename, $return_data = false)
{
extract(parent::load($filename));
$this->clear_sizes();
if (empty($this->image_temp)) {
do {
$this->image_temp = $this->config['temp_dir'] . substr($this->config['temp_append'] . md5(time() * microtime()), 0, 32) . '.png';
} while (file_exists($this->image_temp));
} else {
if (file_exists($this->image_temp)) {
$this->debug('Removing previous temporary image.');
unlink($this->image_temp);
}
}
$this->debug('Temp file: ' . $this->image_temp);
if (!file_exists($this->config['temp_dir']) || !is_dir($this->config['temp_dir'])) {
throw new \Fuel_Exception("The temp directory that was given does not exist.");
} else {
if (!touch($this->config['temp_dir'] . $this->config['temp_append'] . '_touch')) {
throw new \Fuel_Exception("Could not write in the temp directory.");
}
}
$this->exec('convert', '"' . $image_fullpath . '"[0] "' . $this->image_temp . '"');
return $this;
}
示例13: createFile
private static function createFile($file)
{
if (!file_exists($file)) {
@touch($file);
@chmod($file, DEFAULT_PERMISSION);
}
}
示例14: __construct
public final function __construct($method)
{
$this->{$method}();
if ($method == 'install') {
touch(dirname(__FILE__) . '/installed');
}
}
示例15: makeFile
/**
* Create the file if it does not exist.
*
* @param string $fileName
*/
protected function makeFile($fileName)
{
if (file_exists($fileName)) {
return;
}
touch($fileName);
}