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


PHP Zend_Filter::get方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     if (!$request->isPost()) {
         $this->getHelper('Redirector')->goto('index', 'index');
         // action, controller
     }
     $c = Zend_Registry::get('config');
     $apiKey = Zend_Filter::get($request->getPost('apikey'), 'Alnum');
     try {
         $user = User::findByApiKey($apiKey);
         if ($user === null) {
             $this->view->assign('response', 'Invalid API key.');
         } else {
             $user->setIp($request->getServer('REMOTE_ADDR'));
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         $this->view->assign('response', $e->getMessage());
     }
     if (isset($user)) {
         if ($_FILES['file']['error'] === 0) {
             $file = new File();
             $file->setFileName($_FILES['file']['name']);
             $file->setFileSize($_FILES['file']['size']);
             $file->setTmpName($_FILES['file']['tmp_name']);
             $file->setUploadedBy($user);
             try {
                 $url = $file->save();
                 $this->view->assign('response', $url . "\n");
             } catch (Exception $e) {
                 $this->view->assign('response', $e->getMessage());
             }
         } else {
             switch ($_FILES['file']['error']) {
                 case UPLOAD_ERR_OK:
                     break;
                 case UPLOAD_ERR_INI_SIZE:
                     throw new Exception('The uploaded file exceeds the upload_max_filesize directive (' . ini_get('upload_max_filesize') . ') in php.ini.');
                     break;
                 case UPLOAD_ERR_FORM_SIZE:
                     throw new Exception('The uploaded file exceeds the MAX_FILE_SIZE directive' . 'that was specified in the HTML form.');
                     break;
                 case UPLOAD_ERR_PARTIAL:
                     throw new Exception('The uploaded file was only partially uploaded.');
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     throw new Exception('No file was uploaded.');
                     break;
                 case UPLOAD_ERR_NO_TMP_DIR:
                     throw new Exception('Missing a temporary folder.');
                     break;
                 case UPLOAD_ERR_CANT_WRITE:
                     throw new Exception('Failed to write file to disk.');
                     break;
                 default:
                     throw new Exception('Unknown File Error.');
             }
         }
     }
 }
开发者ID:bmaland,项目名称:file2url,代码行数:60,代码来源:StoreController.php

示例2: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $c = Zend_Registry::get('config');
     $ip = $request->getServer('REMOTE_ADDR');
     $accessCode = Zend_Filter::get($request->getParam('accessCode'), 'Alnum');
     try {
         $file = File::findByAccessCode($accessCode);
         if (strlen($accessCode) !== (int) $c->file->accessCodeLength) {
             $this->view->assign('error', 'Erroneous input.');
         } else {
             if ($file === null) {
                 $this->view->assign('error', 'Invalid access code.');
             } else {
                 $this->getHelper('ViewRenderer')->setNoRender();
                 $response = $this->getResponse();
                 if ($file->isAttachment()) {
                     // fix for IE catching or PHP bug issue
                     header("Pragma: public");
                     header("Expires: 0");
                     // set expiration time
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     // browser must download file from server instead of cache
                     // force download dialog
                     header("Content-Type: application/force-download");
                     header("Content-Type: application/octet-stream");
                     header("Content-Type: application/download");
                     header("Content-Disposition: attachment; filename=\"" . $file->getName() . "\";");
                     header("Content-Transfer-Encoding: binary");
                     header("Content-Length: " . filesize($c->fileDir . $file->getName()));
                 } else {
                     $response->setHeader('Content-Type', $file->getType());
                 }
                 if ($file->getExtension() === 'phps' || $file->getExtension() === 'php') {
                     highlight_file($c->fileDir . $file->getName());
                 } else {
                     readfile($c->fileDir . $file->getName());
                 }
             }
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         $this->view->assign('error', $e->getMessage());
     }
 }
开发者ID:bmaland,项目名称:file2url,代码行数:44,代码来源:FetchController.php

示例3: testUsageOfOldStaticFactory

 /**
  * ZF-2105
  */
 public function testUsageOfOldStaticFactory()
 {
     set_error_handler(array($this, 'errorHandlerIgnore'));
     $filteredValue = Zend_Filter::get('1a2b3c4d', 'Digits');
     $this->assertEquals('1234', $filteredValue);
     restore_error_handler();
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:10,代码来源:FilterTest.php

示例4: testStaticFactoryClassNotFound

 /**
  * Ensures that if we specify a validator class basename that doesn't
  * exist in the namespace, get() throws an exception.
  */
 public function testStaticFactoryClassNotFound()
 {
     try {
         $this->assertTrue(Zend_Filter::get('1234', 'UnknownFilter'));
         $this->fail('Expected to catch Zend_Filter_Exception');
     } catch (Zend_Exception $e) {
         $this->assertType('Zend_Filter_Exception', $e, 'Expected exception of type Zend_Filter_Exception, got ' . get_class($e));
         $this->assertEquals("Filter class not found from basename 'UnknownFilter'", $e->getMessage());
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:FilterTest.php

示例5: updateJob

 public function updateJob()
 {
     if ($this->_post) {
         //print_r($this->_post); die;
         //clean possible scriptings
         foreach ($this->_post as $key => $value) {
             //TODO: the files and pahses through the sanit.
             if ($key == 'client' || $key == 'media') {
                 continue;
             } else {
                 $this->_post[$key] = Zend_Filter::get($value, 'StripTags');
             }
         }
         //validate the post
         $validation = $this->validate($this->_post);
         if (isset($validation['Error'])) {
             $validation['post'] = $this->_post;
             return $validation;
         }
         //convert date into zend date object
         $this->_post['datePublished'] = new Zend_Date($this->_post['datePublished']);
         //prepare the files for db insertion (add paths(full and db), identifier ...)
         if (isset($this->_post['media'])) {
             $this->_prepareFilesForDb($this->_post['media']);
         }
         //upload the new files
         if (isset($this->_post['media'])) {
             $return = $this->_upload($this->_post['media']);
             if ($return !== true) {
                 //return the post for the form population
                 $return['post'] = $this->_post;
                 return $return;
             }
         }
         //update data in db
         $oJob = new Showcase_Controller_Action_Helper_Admin_Job();
         $return = $oJob->updateJob($this->_post);
         //confirm
         if ($return == false) {
             //delete the uploaded files
             if (isset($this->_post['media'])) {
                 //Delete the files
                 foreach ($this->_post['media'] as $aFiles) {
                     $this->_deleteFiles($aFiles);
                 }
             }
             //report error to screen
             $return['post'] = $this->_post;
             $return['Error'] = 'There was a problem saving to the database. Please try again later.';
             return $return;
         } else {
             if (isset($this->_post['media'])) {
                 //delete old files since the new ones are there now.
                 foreach ($this->_post['media'] as $key => $value) {
                     if ($key == 'images') {
                         //print $this->_uploadPathImages.$this->_post['oldImage']; die;
                         if (file_exists($this->_uploadPathImages . $this->_post['oldImageName'])) {
                             @unlink($this->_uploadPathImages . $this->_post['oldImageName']);
                             @unlink($this->_uploadPathImages . $this->_post['oldThumbName']);
                         }
                     }
                     if ($key == 'documents') {
                         if (file_exists($this->_uploadPathMedia . $this->_post['oldDocName'])) {
                             @unlink($this->_uploadPathMedia . $this->_post['oldDocName']);
                         }
                     }
                 }
             }
             //flush cache
             Showcase_Admin::flushCache();
             //return success
             return true;
         }
     }
 }
开发者ID:roycocup,项目名称:Tests,代码行数:75,代码来源:Job.php


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