當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。