本文整理汇总了PHP中Files类的典型用法代码示例。如果您正苦于以下问题:PHP Files类的具体用法?PHP Files怎么用?PHP Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Files类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getDirContaints
function getDirContaints($dir, $results = array(), $backDir = "")
{
$allfiles = scandir($dir);
$files = new Files();
foreach ($allfiles as $key => $value) {
if (!in_array($value, array(".", ".."))) {
$timestamp = strtotime($value);
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
$uploadDirInfo = explode("_", basename($path));
if (is_dir($path)) {
$dir_files = scandir($path);
foreach ($dir_files as $k => $v) {
if (!in_array($v, array(".", ".."))) {
$pth = realpath($path . DIRECTORY_SEPARATOR . $v);
if (!is_dir($pth)) {
$data['filename'] = basename($pth);
$data['filepath'] = $path;
$data['user_id'] = $uploadDirInfo['1'];
$data['user_name'] = $uploadDirInfo['0'];
$files->uploadBulkFiles($data);
}
}
}
}
}
}
return 'Files uploaded successfuly';
}
开发者ID:pritam-hajare,项目名称:IGI,代码行数:28,代码来源:IGI_Cron_Job.php
示例2: read
/**
* @remotable
*/
public function read($id, $cat)
{
$out = array();
if ($cat == "projects") {
$projects = $this->db->select("SELECT id, name, dir, date FROM projects ORDER BY date DESC");
foreach ($projects as $item) {
$children = array();
$text = "<b>Date</b>: {$item['date']}<br>";
$text .= "<b>Dir/File</b>: {$item['dir']}<br>";
if (is_dir($item['dir'])) {
array_push($children, array('id' => $item['dir'], 'text' => 'Work Directory', 'cat' => 'dir', 'qtip' => $item['dir'], iconCls => 'work-dir', 'leaf' => false));
} elseif (is_file($item['dir'])) {
array_push($children, array('id' => $item['dir'], 'text' => basename($item['dir']), 'hash' => md5($item['dir']), 'iconCls' => 'php-file', 'leaf' => true));
}
array_push($children, array('id' => 'scans' . $item['id'], 'text' => 'Scannings', 'cat' => 'scans', 'iconCls' => 'scannings', 'leaf' => false));
array_push($children, array('id' => 'vulns' . $item['id'], 'text' => 'Vulnerabilities', 'cat' => 'vulns', 'iconCls' => 'vulns', 'leaf' => false));
array_push($out, array('id' => $item['id'], 'text' => $item['name'], 'iconCls' => 'project', 'cat' => 'project', 'qtipCfg' => array('shadow' => 'frame', 'text' => $text, 'dismissDelay' => 10000), 'leaf' => false, 'children' => $children));
}
} elseif ($cat == "dir") {
include 'Files.php';
$f = new Files();
$out = $f->getList($id);
} elseif ($cat == "scans") {
include 'ScanHistory.php';
$s = new ScanHistory();
$out = $s->read(substr($id, 5));
} elseif ($cat == "vulns") {
include 'Vulnerabilities.php';
$v = new Vulnerabilities();
$out = $v->read(substr($id, 5));
}
return $out;
}
开发者ID:Raz0r,项目名称:PHPWhiteBoxStudio,代码行数:36,代码来源:Projects.php
示例3: testNot
public function testNot()
{
$kirby = $this->kirbyInstance();
$site = $this->siteInstance($kirby);
$page = new Page($site, 'tests/file-extension-case-test');
// unset by a single filename
$files = new Files($page);
$this->assertEquals(2, $files->count());
$modified = $files->not('a.json');
$this->assertEquals(1, $modified->count());
// unset by multiple filenames
$files = new Files($page);
$this->assertEquals(2, $files->count());
$modified = $files->not('a.json', 'b.json');
$this->assertEquals(0, $modified->count());
// unset by array
$files = new Files($page);
$this->assertEquals(2, $files->count());
$modified = $files->not(['a.json', 'b.json']);
$this->assertEquals(0, $modified->count());
// unset by a collection
$files = new Files($page);
$this->assertEquals(2, $files->count());
$modified = $files->not($files);
$this->assertEquals(0, $modified->count());
}
开发者ID:nsteiner,项目名称:kdoc,代码行数:26,代码来源:FilesTest.php
示例4: noavatarAction
public function noavatarAction()
{
$files = new Files();
$file = $this->_properties->getProperty('avatar_image');
$this->_properties->deleteProperty('avatar_image');
$files->deleteFile($file);
$this->_forward('index');
}
开发者ID:kreativmind,项目名称:storytlr,代码行数:8,代码来源:ProfileController.php
示例5: __construct
/**
* Constructor
*
* @param Files The parent files collection
* @param string The filename
*/
public function __construct(Files $files, $filename)
{
$this->site = $files->site();
$this->page = $files->page();
$this->files = $files;
$this->root = $this->files->page()->root() . DS . $filename;
parent::__construct($this->root);
}
开发者ID:gBokiau,项目名称:kirby,代码行数:14,代码来源:file.php
示例6: actionView
/**
* Вывод инфы о бане
* @param integer $id ID бана
*/
public function actionView($id)
{
// Подгружаем комментарии и файлы
$files = new Files();
//$this->performAjaxValidation($files);
$files->unsetAttributes();
$comments = new Comments();
$comments->unsetAttributes();
// Подгружаем баны
$model = Bans::model()->with('admin')->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$geo = false;
// Проверка прав на просмотр IP
$ipaccess = Webadmins::checkAccess('ip_view');
if ($ipaccess) {
$geo = array('city' => 'Н/А', 'region' => 'Не определен', 'country' => 'Не определен', 'lat' => 0, 'lng' => 0);
$get = @file_get_contents('http://ipgeobase.ru:7020/geo?ip=' . $model->player_ip);
if ($get) {
$xml = @simplexml_load_string($get);
if (!empty($xml->ip)) {
$geo['city'] = $xml->ip->city;
$geo['region'] = $xml->ip->region;
$geo['country'] = $xml->ip->country;
$geo['lat'] = $xml->ip->lat;
$geo['lng'] = $xml->ip->lng;
}
}
}
// Добавление файла
if (isset($_POST['Files'])) {
// Задаем аттрибуты
$files->attributes = $_POST['Files'];
$files->bid = intval($id);
if ($files->save()) {
$this->refresh();
}
}
// Добавление комментария
if (isset($_POST['Comments'])) {
//exit(print_r($_POST['Comments']));
$comments->attributes = $_POST['Comments'];
$comments->bid = $id;
if ($comments->save()) {
$this->refresh();
}
}
// Выборка комментариев
$c = new CActiveDataProvider($comments, array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
// Выборка файлов
$f = new CActiveDataProvider(Files::model(), array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
// История банов
$history = new CActiveDataProvider('Bans', array('criteria' => array('condition' => '`bid` <> :hbid AND (`player_ip` = :hip OR `player_id` = :hid)', 'params' => array(':hbid' => $id, ':hip' => $model->player_ip, ':hid' => $model->player_id)), 'pagination' => array('pageSize' => 5)));
// Вывод всего на вьюху
$this->render('view', array('geo' => $geo, 'ipaccess' => $ipaccess, 'model' => $model, 'files' => $files, 'comments' => $comments, 'f' => $f, 'c' => $c, 'history' => $history));
}
开发者ID:urichalex,项目名称:CS-Bans,代码行数:61,代码来源:BansController.php
示例7: backupDB
public function backupDB()
{
$dumper = new dbMaster();
$sql = $dumper->getDump(false);
$file = new Files();
$file->name = "DB Backup " . date("d-m-Y_H_i") . ".sql";
$file->path = '.';
$file->save();
$file->writeFile($sql);
$this->DBback = $file->id;
}
开发者ID:hkhateb,项目名称:linet3,代码行数:11,代码来源:Update.php
示例8: action_index
public function action_index()
{
$record = new Files();
$record->parent_id = $_POST['parent_id'];
$record->text = $_POST['text'];
$record->extension = $_POST['extension'];
$record->leaf = $_POST['leaf'];
$record->save();
$array = array('success' => 'true', 'msg' => 'Record added successfully');
$json = json_encode($array);
return $json;
}
开发者ID:SerdarSanri,项目名称:LextJS,代码行数:12,代码来源:filesform.php
示例9: sqhrdm_get_download_link
/**
* Helper function to use within theme files for hardcoded links
*
* @param url $file_url URL of file
* @param boolean $force_download Wheather to force download or not
* @return url Parsed link
*/
function sqhrdm_get_download_link($file_url = null, $force_download = true)
{
if (!$file_url) {
return '#';
}
require_once SQHR_DM_PLUGIN_PATH . 'system/controllers/class.files.php';
$files = new Files();
$file_id = $files->get_file_id($file_url);
$return .= '?process_download=';
$return .= $file_id;
$return .= !$force_download ? '&pd_force=no' : '';
return $return;
}
开发者ID:qaribhaider,项目名称:sqhr-download-manager,代码行数:20,代码来源:helpers.php
示例10: add
public function add($data)
{
$data['addtime'] = time();
$File = new Files();
foreach ($data as $field => $value) {
$File->{$field} = $value;
}
if (!$File->create()) {
$this->outputErrors($File);
return false;
}
return true;
}
开发者ID:Crocodile26,项目名称:php-1,代码行数:13,代码来源:Files.php
示例11: upload
public function upload(Request $request)
{
$file = $request->file;
$imageName = md5(time() * rand(1, 100)) . '.' . $file->getClientOriginalExtension();
$f = new Files();
$f->name = $imageName;
$f->mimeType = $file->getMimeType();
$f->size = $file->getSize();
$f->user_id = 1;
$f->produto_id = $request->input('produto_id');
$file->move(base_path() . '/public/imagens/', $imageName);
$f->save();
return 'OK';
}
开发者ID:eduardolcouto,项目名称:galeriaLaravel,代码行数:14,代码来源:ImagensController.php
示例12: renderDefault
public function renderDefault()
{
$files = $this->files->order($this->order . " " . $this->sort);
// vyhledavani
if ($this->q) {
$files->where("file.name LIKE ?", "%" . $this->q . "%");
$this['search']['q']->setDefaultValue($this->q);
$this->template->search = TRUE;
} else {
$this->template->search = FALSE;
}
$this->pagerFiles->itemCount = $files->count();
$this->template->files = $files->limit($this->pagerFiles->getLimit(), $this->pagerFiles->getOffset());
}
开发者ID:soundake,项目名称:pd,代码行数:14,代码来源:FilesPresenter.php
示例13: listFiles
public function listFiles()
{
Zend_Loader::loadClass('Files');
$files = new Files();
$list = $files->listFiles('public/files/uploaded/');
sort($list);
$all = array();
foreach ($list as $filename) {
$row['name'] = $filename;
$row['filesize'] = filesize('public/files/uploaded/' . $filename);
array_push($all, $row);
}
return $all;
}
开发者ID:stinger,项目名称:mailer,代码行数:14,代码来源:FilesService.php
示例14: createMongoAction
public function createMongoAction()
{
$file = new Files();
$file->type = "video";
$file->name = "Astro Boy";
$file->year = 1952;
if ($file->save() == false) {
echo "Umh, We can't store files right now: \n";
foreach ($file->getMessages() as $message) {
echo $message, "\n";
}
} else {
echo "Great, a new file was saved successfully !";
}
}
开发者ID:Xavier94,项目名称:mydav,代码行数:15,代码来源:ListController.php
示例15: listAction
public function listAction()
{
$format = $this->_getParam('format', 'ajax');
switch ($format) {
case 'xml':
$this->_helper->layout->setLayout('xml');
$this->_helper->viewRenderer('list-xml');
break;
default:
$this->_helper->layout->setLayout('ajax');
}
Zend_Loader::loadClass('Files');
$files = new Files();
$this->view->list = $files->listFiles('public/files/uploaded/');
}
开发者ID:stinger,项目名称:mailer,代码行数:15,代码来源:IndexController.php
示例16: __construct
/**
* @constructor
*/
public function __construct($data_folder = '')
{
// load the config file.
$this->config = new Config();
$this->config->load($data_folder);
// load the templates.
$this->templates = new Templates();
$this->templates->load($data_folder);
// loading data files.
$this->files = new Files();
$this->files->load($data_folder, $this->config->get('pages_data'));
// initialize database.
$this->db = new Database();
//
$this->renders = new Renders();
}
开发者ID:diasbruno,项目名称:stc,代码行数:19,代码来源:DataApplication.php
示例17: drawFiles
/**
* Draw the files in an table.
*/
function drawFiles($list, &$manager)
{
global $relative;
foreach ($list as $entry => $file) {
?>
<td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">
<a href="javascript:;" onclick="selectImage('<?php
echo $file['relative'];
?>
', '<?php
echo $entry;
?>
', <?php
echo $file['image'][0];
?>
, <?php
echo $file['image'][1];
?>
);"title="<?php
echo $entry;
?>
- <?php
echo Files::formatSize($file['stat']['size']);
?>
"><img src="<?php
echo $manager->getThumbnail($file['relative']);
?>
" alt="<?php
echo $entry;
?>
- <?php
echo Files::formatSize($file['stat']['size']);
?>
"/></a>
</td></tr><tr><td class="edit">
<a href="images.php?dir=<?php
echo $relative;
?>
&delf=<?php
echo rawurlencode($file['relative']);
?>
" title="Trash" onclick="return confirmDeleteFile('<?php
echo $entry;
?>
');"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a><a href="javascript:;" title="Edit" onclick="editImage('<?php
echo rawurlencode($file['relative']);
?>
');"><img src="img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a>
<?php
if ($file['image']) {
echo $file['image'][0] . 'x' . $file['image'][1];
} else {
echo $entry;
}
?>
</td></tr></table></td>
<?php
}
//foreach
}
开发者ID:Chitu10993610,项目名称:azx111,代码行数:63,代码来源:images.php
示例18: personPrepare
protected static function personPrepare()
{
return PersonModel::join(PersonLangModel::getTableName(), PersonLangModel::getField("person_id"), '=', PersonModel::getField("id"))->join(PersonRelModel::getTableName(), PersonRelModel::getField("person_id"), '=', PersonModel::getField("id"))->leftJoin(Files::getTableName(), function ($join) {
$join->on(Files::getField("module_id"), '=', PersonModel::getField("id"));
$join->on(Files::getField("module_name"), '=', DB::raw("'person'"));
})->where(PersonLangModel::getField("lang_id"), \WebAPL\Language::getId())->orderBy('first_name', 'asc')->orderBy('last_name', 'asc');
}
开发者ID:vcorobceanu,项目名称:WebAPL,代码行数:7,代码来源:PersonModel.php
示例19: folder_contents
/**
* Get all folders and files within a folder
*
* @param int $parent The id of this folder
* @return array
*
**/
public static function folder_contents($parent = 0, $type = null)
{
// they can also pass a url hash such as #foo/bar/some-other-folder-slug
if (!is_numeric($parent)) {
$segment = explode('/', trim($parent, '/#'));
$result = ci()->file_folders_m->get_by('slug', array_pop($segment));
$parent = $result ? $result->id : 0;
}
$folders = ci()->file_folders_m->where('parent_id', $parent)->where('hidden', 0)->order_by('sort')->get_all();
// $files = ci()->file_m->where(array('folder_id' => $parent))
// ->order_by('sort')
// ->get_all();
$files = ci()->file_m->where(array('folder_id' => $parent, 'type' => $type))->order_by('sort')->get_all();
// let's be nice and add a date in that's formatted like the rest of the CMS
if ($folders) {
foreach ($folders as &$folder) {
$folder->formatted_date = format_date($folder->date_added);
$folder->file_count = ci()->file_m->count_by('folder_id', $folder->id);
}
}
if ($files) {
ci()->load->library('keywords/keywords');
foreach ($files as &$file) {
$file->keywords_hash = $file->keywords;
$file->keywords = ci()->keywords->get_string($file->keywords);
$file->formatted_date = format_date($file->date_added);
}
}
return Files::result(true, null, null, array('folder' => $folders, 'file' => $files, 'parent_id' => $parent));
}
开发者ID:jacksun101,项目名称:PyroAddons,代码行数:37,代码来源:imagepicker_m.php
示例20: __construct
/**
* Sets up internal variables with the arguments given
* @param string $label The (human-readable) label for the form element
* @param string $name The (machine-readable) name of the element
* @param array $data The url to the image-object
* @param string $validate Adds a validation class to the element
* @param string $description Add a description to the form element
* @param bool $preview Adds a preview of the choosen image
* @return void
*/
function __construct($label, $name, $value = '', $validate = false, $description = false, $preview = true, $dir = false, $class = false)
{
$this->label = $label;
$this->value = $value;
$this->name = $name;
$this->validate = $validate;
$this->preview = $preview;
$this->description = $description;
$this->class = $class;
global $Controller;
if ($dir && (is_a($dir, 'User') || is_a($dir, 'Group'))) {
$dir = Files::userDir($dir);
}
if ($dir) {
if (!is_object($dir)) {
$dir = $Controller->{(string) $dir};
}
if (!$dir->mayI(READ)) {
$dir = false;
}
$this->dir = $dir->ID;
} else {
$this->dir = false;
}
}
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:35,代码来源:ImagePicker.php
注:本文中的Files类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论