示例#1
0
 public function testGetExtensionFail()
 {
     $this->assertType('PEAR_Error', $this->mte->getExtension(null));
     $this->assertType('PEAR_Error', $this->mte->getExtension(''));
     $this->assertType('PEAR_Error', $this->mte->getExtension('n'));
     $this->assertType('PEAR_Error', $this->mte->getExtension('n/n'));
 }
示例#2
0
文件: File.php 项目: Br3nda/StatusNet
 static function filename($profile, $basename, $mimetype)
 {
     require_once 'MIME/Type/Extension.php';
     $mte = new MIME_Type_Extension();
     try {
         $ext = $mte->getExtension($mimetype);
     } catch (Exception $e) {
         $ext = strtolower(preg_replace('/\\W/', '', $mimetype));
     }
     $nickname = $profile->nickname;
     $datestamp = strftime('%Y%m%dT%H%M%S', time());
     $random = strtolower(common_confirmation_code(32));
     return "{$nickname}-{$datestamp}-{$random}.{$ext}";
 }
示例#3
0
文件: File.php 项目: Grasia/bolotweet
 static function filename($profile, $basename, $mimetype)
 {
     require_once 'MIME/Type/Extension.php';
     // We have to temporarily disable auto handling of PEAR errors...
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $mte = new MIME_Type_Extension();
     $ext = $mte->getExtension($mimetype);
     if (PEAR::isError($ext)) {
         $ext = strtolower(preg_replace('/\\W/', '', $mimetype));
     }
     // Restore error handling.
     PEAR::staticPopErrorHandling();
     $nickname = $profile->nickname;
     $datestamp = strftime('%Y%m%dT%H%M%S', time());
     $random = strtolower(common_confirmation_code(32));
     return "{$nickname}-{$datestamp}-{$random}.{$ext}";
 }