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


PHP validater::checkFileName方法代码示例

本文整理汇总了PHP中validater::checkFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP validater::checkFileName方法的具体用法?PHP validater::checkFileName怎么用?PHP validater::checkFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validater的用法示例。


在下文中一共展示了validater::checkFileName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUpload

 /**
  * Get upload files. 
  * 
  * @access public
  * @return array
  */
 public function getUpload()
 {
     $files = array();
     if (!isset($_FILES['files'])) {
         return $files;
     }
     if (!$this->loadModel('file')->canUpload()) {
         return $files;
     }
     extract($_FILES['files']);
     foreach ($name as $id => $filename) {
         if (empty($filename)) {
             continue;
         }
         if (!validater::checkFileName($filename)) {
             continue;
         }
         $file['extension'] = $this->file->getExtension($filename);
         $file['size'] = $size[$id];
         $file['tmpname'] = $tmp_name[$id];
         $files[] = $file;
     }
     return $files;
 }
开发者ID:eric0614,项目名称:chanzhieps,代码行数:30,代码来源:model.php

示例2: getUpload

 /**
  * Get info of uploaded files.
  * 
  * @param  string $htmlTagName 
  * @access public
  * @return array
  */
 public function getUpload($htmlTagName = 'files')
 {
     $files = array();
     if (!isset($_FILES[$htmlTagName])) {
         return $files;
     }
     $this->app->loadClass('purifier', true);
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Cache.DefinitionImpl', null);
     $purifier = new HTMLPurifier($config);
     /* If the file var name is an array. */
     if (is_array($_FILES[$htmlTagName]['name'])) {
         extract($_FILES[$htmlTagName]);
         foreach ($name as $id => $filename) {
             if (empty($filename)) {
                 continue;
             }
             if (!validater::checkFileName($filename)) {
                 continue;
             }
             $file['extension'] = $this->getExtension($filename);
             $file['pathname'] = $this->setPathName($id, $file['extension']);
             $file['title'] = !empty($_POST['labels'][$id]) ? htmlspecialchars($_POST['labels'][$id]) : str_replace('.' . $file['extension'], '', $filename);
             $file['title'] = $purifier->purify($file['title']);
             $file['size'] = $size[$id];
             $file['tmpname'] = $tmp_name[$id];
             $files[] = $file;
         }
     } else {
         if (empty($_FILES[$htmlTagName]['name'])) {
             return $files;
         }
         extract($_FILES[$htmlTagName]);
         if (!validater::checkFileName($name)) {
             return array();
         }
         $file['extension'] = $this->getExtension($name);
         $file['pathname'] = $this->setPathName(0, $file['extension']);
         $file['title'] = !empty($_POST['labels'][0]) ? htmlspecialchars($_POST['labels'][0]) : substr($name, 0, strpos($name, $file['extension']) - 1);
         $file['title'] = $purifier->purify($file['title']);
         $file['size'] = $size;
         $file['tmpname'] = $tmp_name;
         return array($file);
     }
     return $files;
 }
开发者ID:jsyinwenjun,项目名称:zentao,代码行数:53,代码来源:model.php

示例3: edit

 /**
  * Edit file.
  * 
  * @param  int    $fileID 
  * @access public
  * @return void
  */
 public function edit($fileID)
 {
     $this->replaceFile($fileID);
     $fileInfo = fixer::input('post')->remove('upFile')->get();
     if (!validater::checkFileName($fileInfo->title)) {
         return false;
     }
     $fileInfo->lang = 'all';
     $this->dao->update(TABLE_FILE)->data($fileInfo)->autoCheck()->batchCheck($this->config->file->require->edit, 'notempty')->where('id')->eq($fileID)->exec();
     $this->dao->setAutoLang(false)->update(TABLE_FILE)->data($fileInfo)->autoCheck()->batchCheck($this->config->file->require->edit, 'notempty')->where('id')->eq($fileID)->exec();
 }
开发者ID:peirancao,项目名称:chanzhieps,代码行数:18,代码来源:model.php

示例4: sourceEdit

 /**
  * Edit for the source file. 
  * 
  * @param  int $fileID 
  * @access public
  * @return void
  */
 public function sourceEdit($fileID)
 {
     $this->file->setSavePath('source');
     $file = $this->file->getById($fileID);
     if (!empty($_POST)) {
         if (!$this->file->checkSavePath()) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorUnwritable));
         }
         if ($this->post->filename == false or $this->post->filename == '') {
             $this->send(array('result' => 'fail', 'message' => $this->lang->file->nameEmpty));
         }
         $filename = $this->post->filename;
         if (!validater::checkFileName($filename)) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->file->evilChar));
         }
         if (!$this->post->continue) {
             $extension = $this->file->getExtension($_FILES['upFile']['name']);
             $sameUpFile = $this->file->checkSameFile(str_replace('.' . $extension, '', $_FILES['upFile']['name']), $fileID);
             $sameFilename = $this->file->checkSameFile($this->post->filename, $fileID);
             if (!empty($sameUpFile) or !empty($sameFilename)) {
                 $this->send(array('result' => 'fail', 'error' => $this->lang->file->sameName));
             }
         }
         $result = $this->file->sourceEdit($file, $filename);
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('file', 'browseSource')));
         }
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $this->view->title = $this->lang->file->edit;
     $this->view->modalWidth = 500;
     $this->view->file = $file;
     $this->display();
 }
开发者ID:wenyinos,项目名称:chanzhieps,代码行数:41,代码来源:control.php

示例5: sourceEdit

 /**
  * Edit for the source file. 
  * 
  * @param  int $fileID 
  * @access public
  * @return void
  */
 public function sourceEdit($fileID)
 {
     $this->file->setSavePath('source');
     $file = $this->file->getById($fileID);
     if (!empty($_POST)) {
         if (!$this->file->checkSavePath()) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorUnwritable));
         }
         if ($this->post->filename == false or $this->post->filename == '') {
             $this->send(array('result' => 'fail', 'message' => $this->lang->file->nameEmpty));
         }
         $filename = $this->post->filename;
         if (!validater::checkFileName($filename)) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->file->evilChar));
         }
         $result = $this->file->sourceEdit($file, $filename);
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('file', 'browseSource')));
         }
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $this->view->title = $this->lang->file->edit;
     $this->view->modalWidth = 500;
     $this->view->file = $file;
     $this->display();
 }
开发者ID:peirancao,项目名称:chanzhieps,代码行数:33,代码来源:control.php


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