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')); }
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}"; }
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}"; }