当前位置: 首页>>代码示例>>PHP>>正文


PHP Files类代码示例

本文整理汇总了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';
}
开发者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


注:本文中的Files类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。