本文整理汇总了PHP中Files类的典型用法代码示例。如果您正苦于以下问题:PHP Files类的具体用法?PHP Files怎么用?PHP Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Files类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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';
}
示例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;
}
示例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());
}
示例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');
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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';
}
示例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());
}
示例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;
}
示例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 !";
}
}
示例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/');
}