本文整理汇总了PHP中File::create方法的典型用法代码示例。如果您正苦于以下问题:PHP File::create方法的具体用法?PHP File::create怎么用?PHP File::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @return void
*/
public function execute()
{
if (is_null($this->file)) {
throw new \Exception('ファイルを指定してください');
}
$this->file->create();
}
示例2: __construct
/**
* Constructs a new Debug-Object.
*
* The first parameter has to be the file name with extension, but without directory. The second
* parameter has to be a valid and existing directory path with trainling directory separator
* (make sure the directory is writable). Standard value for this paramteer is null. If the
* directory is null or invalid "data/logs/" will be used. If the specified file doesn't exist
* it will created. If it is not possible to create a file a NonFatalException will be thrown.
*
* @param string File for saving the logdata
* @param string Valid Directory for saving the logfile or null (directory will be "data/logs/")
* @throws NonFatalException
*/
public function __construct($file, $dir = null) {
if ($dir === null || is_dir($dir) === false) {
$dir = 'data/logs/';
}
$this->file = new File($dir.basename($file));
if ($this->file->create() === false) {
throw new NonFatalException('Could not create log file "'.$this->file->relPath().'".');
}
if ($this->file->readable() === false || $this->file->writable() === false) {
$this->file->setPermissions(666);
}
$this->logs = array();
$this->benchmarks = array();
$this->temp = array();
}
示例3: User
function step2($data)
{
//eseguo lo script MySQL
if (!$this->mySqlInstall()) {
$this->validationErrors['script_db'] = 'Errore nella compilazione del database';
return false;
}
//inserisco i dati di configurazione dell'utente admin
App::import('model', 'User');
$User = new User();
$User->create(array('User' => array('first_name' => $data['admin_first_name'], 'last_name' => $data['admin_last_name'], 'username' => $data['admin_username'], 'password' => Security::hash($data['admin_pwd'], null, true), 'email' => $data['admin_email'], 'role' => 0, 'active' => 1)));
if (!$User->save()) {
return false;
}
//scrivo il file installed.txt nella directory config
App::import('core', 'File');
$installedFile = new File(APP . 'config' . DS . 'installed.txt');
$installedFile->create();
//imposto correttamente i permessi sulle directories per la produzione
if (!$this->setFolderPermissions($this->writableDirsForInstall, '0755')) {
return false;
}
if (!$this->setFolderPermissions($this->writableDirsForProduction, '0755')) {
return false;
}
//tutto ok
return true;
}
示例4: action_zip
public function action_zip($articulo_id = null)
{
is_null($articulo_id) and Response::redirect('diagramador');
$articulos = Model_Articulo::find('all', array('related' => array('fotos', 'seccion'), 'where' => array(array('id', '=', $articulo_id))));
$files_to_zip = array();
$archivo_informacion = '';
foreach ($articulos as $articulo) {
$archivo_informacion .= "Nombre del Articulo: " . $articulo->nombre . "\n";
$archivo_informacion .= "Seccion del Articulo: " . $articulo->seccion->descripcion . "\n";
$archivo_informacion .= "Fecha del Articulo: " . date('Y-m-d H:i:s', $articulo->fecha_publicacion) . "\n";
$archivo_informacion .= "\n ==========================\n";
foreach ($articulo->fotos as $foto) {
if ($foto->estado == 1) {
array_push($files_to_zip, $foto->imagen);
$nombre_archivo = str_ireplace(".jpg", "-" . $articulo->pagina->descripcion . ".jpg", $foto->imagen);
$pieces = explode("/", $nombre_archivo);
$count_foto = count($pieces);
$nombre_archivo = $pieces[$count_foto - 1];
$archivo_informacion .= $nombre_archivo . "\n" . "Medida: " . $foto->dimension->descipcion . "\n" . "Pagina: " . $articulo->pagina->descripcion . "\n ==========================\n";
}
}
}
$time = time();
File::create(DOCROOT . "zip/", "info_{$articulo_id}_{$time}.txt", $archivo_informacion);
array_push($files_to_zip, "/gr/public/zip/info_{$articulo_id}_{$time}.txt");
Zip::create_zip($files_to_zip, $articulo_id, true, $time, $articulo->pagina->descripcion);
}
示例5: create
/**
* Create method for this handler
*
* @return array of assets created
**/
public function create()
{
// Set the asset type to video
$this->asset['type'] = 'file';
$this->asset['subtype'] = 'swf';
// Call the primary create method on the file asset handler
return parent::create();
}
示例6: finishInstall
/**
* Finish install, set .installed file on
* module path
*
* @param string $module
* @return boolean
*/
public function finishInstall($module)
{
$modulePath = CLOGGY_PATH_MODULE . $module . DS;
$modulePathInstalled = $modulePath . '.installed';
$folder = new Folder();
$folder->chmod($modulePath, 0755, true);
$file = new File($modulePathInstalled);
return $file->create();
}
示例7: execute
/**
* @return void
*/
public function execute()
{
if (is_null($this->file)) {
throw new \Exception('ファイルを指定してください');
}
$file = new File();
$file->setPath('copy_of_' . $this->file->getPath());
$file->create();
}
示例8: __construct
/**
* Constructs a new Debug-Object.
*
* The first parameter has to be the file name with extension, but without directory.
* Standard value is null, then the filename will be "internal.log".
* The second parameter has to be a valid and existing directory with trailing slash.
* Standard value is also null, then the directory will be "data/logs/" (make sure that it is writable).
* If the specified file doesn't exist, it will created.
* If it is not possible to create a file nn Exception will be thrown.
*
* @param string File for saving the logdata or null (filename is internal.log then)
* @param string Directory for saving the logfile or null (directory is data/logs/ then)
* @throws Exception
*/
public function __construct($file = null, $dir = null)
{
if ($dir == null || is_dir($dir) == false) {
$dir = 'data/logs/';
}
if ($file == null) {
$file = 'internal.log';
}
$this->file = new File($dir . basename($file));
if ($this->file->create() == false) {
throw new Exception('Could not create log file in method Debug::__construct().');
}
if ($this->file->readable() == false || $this->file->writable() == false) {
$writable = new CHMOD(666);
$this->file->setChmod($writable);
}
$this->logs = array();
$this->benchmarks = array();
$this->temp = array();
}
示例9: downloadModule
public function downloadModule($fileUrl, $savePath, $unzip = 'no')
{
// self::uploadFromUrl($fileUrl,$savePath);
$imgData = Http::getDataUrl($fileUrl);
$fileName = basename($fileUrl);
$fullPath = ROOT_PATH . $savePath . $fileName;
File::create($fullPath, $imgData);
if ($unzip != 'no') {
self::unzipModule($fullPath, 'yes');
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
if (!Auth::user()->can('create-audio')) {
return view('errors.denied');
}
$file_hash = md5(Input::file('audio')->getClientOriginalName() . time());
$file_details = ['name' => Input::file('audio')->getClientOriginalName(), 'title' => Input::get('title'), 'description' => Input::get('description'), 'file_hash' => $file_hash, 'extension' => Input::file('audio')->getClientOriginalExtension(), 'type' => 2];
File::create($file_details);
Input::file('audio')->move(base_path() . '/files/audio/', $file_hash . '.' . Input::file('audio')->getClientOriginalExtension());
return view('audio.index');
}
示例11: edit
public function edit()
{
if (!($match = Uri::match('\\/edit\\/(\\w+)'))) {
Redirect::to(ADMINCP_URL);
}
$themeName = $match[1];
$thePath = THEMES_PATH . $themeName . '/';
if (!is_dir($thePath)) {
Redirect::to(ADMINCP_URL);
}
$subPath = Request::get('path', '');
if (preg_match('/\\.\\./i', $subPath)) {
// Alert::make('You can not do this action.');
$subPath = dirname($subPath);
}
$thePath .= $subPath;
$queryPath = $thePath;
$pageData = array();
if (preg_match('/.*?\\.\\w+/i', $subPath)) {
if (!preg_match('/(\\w+)\\/\\w+\\.\\w+/i', $subPath, $match)) {
$subPath = dirname($subPath);
} else {
$subPath = $match[1];
}
$pageData['file']['name'] = basename($queryPath);
$pageData['file']['data'] = file_get_contents($queryPath);
$queryPath = dirname($queryPath);
if (Request::has('btnSave')) {
$savePath = $queryPath . '/' . $pageData['file']['name'];
$saveData = trim(Request::get('send.file_content', ''));
File::create($savePath, $saveData);
$pageData['file']['data'] = file_get_contents($savePath);
}
}
$listFiles = Dir::all($queryPath);
if (isset($listFiles[0]) == '.') {
unset($listFiles[0]);
}
if (isset($listFiles[1]) == '..') {
unset($listFiles[1]);
}
sort($listFiles);
$pageData['listFiles'] = $listFiles;
$pageData['themeName'] = $themeName;
$pageData['themePath'] = THEMES_PATH . $themeName . '/';
$pageData['thisPath'] = $queryPath;
$pageData['subPath'] = $subPath . '/';
// print_r($pageData['listFiles']);die();
System::setTitle('Edit theme ' . $themeName . ' - ' . ADMINCP_TITLE);
View::make('admincp/head', array());
self::makeContents('themeEdit', $pageData);
View::make('admincp/footer');
}
示例12: settingProcess
function settingProcess()
{
$alert = '<div class="alert alert-warning">Error. Check information again, pls!</div>';
$valid = Validator::make(array('send.email' => 'email|slashes', 'send.secret' => 'slashes', 'send.order_status' => 'slashes', 'send.pending_status' => 'slashes', 'send.cancelled_status' => 'slashes', 'send.failed_status' => 'slashes', 'send.chargeback_status' => 'slashes'));
if (!$valid) {
return $alert;
}
$saveData = json_encode(Request::get('send'));
File::create(PAYMENTMETHOD_PATH . 'setting.json', $saveData);
$alert = '<div class="alert alert-success">Completed. Save changes success!</div>';
return $alert;
}
示例13: write
/**
* Write a message to the log file.
*
* <code>
* // Write an "error" message to the log file
* Log::write('error', 'Something went horribly wrong!');
*
* // Write an "error" message using the class' magic method
* Log::error('Something went horribly wrong!');
*
* // Log an arrays data
* Log::write('info', array('name' => 'Sawny', 'passwd' => '1234', array(1337, 21, 0)), true);
* //Result: Array ( [name] => Sawny [passwd] => 1234 [0] => Array ( [0] => 1337 [1] => 21 [2] => 0 ) )
* //If we had omit the third parameter the result had been: Array
* </code>
*
* @param string $type
* @param string $message
* @return void
*/
public static function write($type, $message, $prettyPrint = false)
{
if (!isset(static::$_logFile)) {
static::$_logFile = LOGS_PATH . DS . date('Y-m-d') . '.log';
}
if (!File::exists(static::$_logFile)) {
File::create(static::$_logFile);
}
$message = false !== $prettyPrint ? print_r($message, true) : $message;
$message = static::format($type, $message);
File::append(static::$_logFile, $message);
}
示例14: w_serverlog
function w_serverlog($server, $log)
{
$logfile = TMP . "server/" . $server . ".log";
$file = new File($logfile);
if ($file->exists()) {
$file->append('
[' . date('Y-m-d H:i:s') . '] ' . $log);
} else {
$file->create();
$file->append('[' . date('Y-m-d H:i:s') . '] ' . $log);
}
}
示例15: detect_update_system
function detect_update_system()
{
$loadData = Update::get();
$encodeData = serialize($loadData);
$md5Data = md5($encodeData);
$path = CACHES_PATH . 'dbcache/plugin/autoupdate/';
$filePath = $path . $md5Data . '.cache';
if (!file_exists($filePath)) {
Update::make();
File::create($filePath, 'ok');
}
}