private function createUploadDir()
    {
        $uploadDirectory = \FileUtil::getDataDirectory() . '/cmfcmf-media-module/media';
        if (!is_dir($uploadDirectory)) {
            mkdir($uploadDirectory, 0777, true);
        }
        $htaccess = <<<TXT
deny from all
<FilesMatch "(?i)\\.(css|js|rss|png|gif|jpg|jpeg|psd|svg|txt|rtf|xml|pdf|sdt|odt|doc|docx|pps|ppt|pptx|xls|xlsx|mp3|wav|wma|avi|flv|mov|mp4|rm|vob|wmv|gz|rar|tar.gz|zip|ogg|webm)\$">
order allow,deny
allow from all
</FilesMatch>
TXT;
        file_put_contents($uploadDirectory . '/.htaccess', $htaccess);
    }
示例#2
0
 /**
  * Uninstall Reviews.
  *
  * @return boolean True on success, false otherwise.
  */
 public function uninstall()
 {
     // delete stored object workflows
     $result = Zikula_Workflow_Util::deleteWorkflowsForModule($this->getName());
     if ($result === false) {
         return LogUtil::registerError($this->__f('An error was encountered while removing stored object workflows for the %s extension.', array($this->getName())));
     }
     try {
         DoctrineHelper::dropSchema($this->entityManager, $this->listEntityClasses());
     } catch (\Exception $e) {
         if (System::isDevelopmentMode()) {
             return LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
         }
         return LogUtil::registerError($this->__f('An error was encountered while dropping tables for the %s extension.', array($this->name)));
     }
     // unregister persistent event handlers
     EventUtil::unregisterPersistentModuleHandlers($this->name);
     // unregister hook subscriber bundles
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // remove all module vars
     $this->delVars();
     // remove category registry entries
     ModUtil::dbInfoLoad('Categories');
     DBUtil::deleteWhere('categories_registry', 'modname = \'' . $this->name . '\'');
     // remove all thumbnails
     $manager = $this->getServiceManager()->getService('systemplugin.imagine.manager');
     $manager->setModule($this->name);
     $manager->cleanupModuleThumbs();
     // remind user about upload folders not being deleted
     $uploadPath = FileUtil::getDataDirectory() . '/' . $this->name . '/';
     LogUtil::registerStatus($this->__f('The upload directories at [%s] can be removed manually.', $uploadPath));
     // uninstallation successful
     return true;
 }
 public function getPathToUploadTo($defaultPath)
 {
     unset($defaultPath);
     return \FileUtil::getDataDirectory() . '/cmfcmf-media-module/watermarks';
 }
示例#4
0
 /**
  * Retrieve the base path for given object type and upload field combination.
  *
  * @param string  $objectType   Name of treated entity type.
  * @param string  $fieldName    Name of upload field.
  * @param boolean $ignoreCreate Whether to ignore the creation of upload folders on demand or not.
  *
  * @return mixed Output.
  * @throws Exception if invalid object type is given.
  */
 public function getFileBaseFolder($objectType, $fieldName, $ignoreCreate = false)
 {
     if (!in_array($objectType, $this->getObjectTypes())) {
         throw new Exception('Error! Invalid object type received.');
     }
     $basePath = FileUtil::getDataDirectory() . '/Reviews/';
     switch ($objectType) {
         case 'review':
             $basePath .= 'reviews/coverupload/';
             break;
     }
     $result = DataUtil::formatForOS($basePath);
     if (substr($result, -1, 1) != '/') {
         // reappend the removed slash
         $result .= '/';
     }
     if (!is_dir($result) && !$ignoreCreate) {
         $this->checkAndCreateAllUploadFolders();
     }
     return $result;
 }
示例#5
0
 /**
  * Retrieve the base path for given object type and upload field combination.
  *
  * @param string $objectType Name of treated entity type.
  * @param string $fieldName  Name of upload field.
  * @param array  $args       Additional arguments.
  *
  * @return mixed Output.
  */
 public static function getFileBaseFolder($objectType, $fieldName)
 {
     if (!in_array($objectType, self::getObjectTypes())) {
         $objectType = self::getDefaultObjectType();
     }
     $basePath = FileUtil::getDataDirectory() . '/MUBoard/';
     switch ($objectType) {
         case 'posting':
             $basePath .= 'postings/';
             switch ($fieldName) {
                 case 'firstImage':
                     $basePath .= 'firstimage/';
                     break;
                 case 'secondImage':
                     $basePath .= 'secondimage/';
                     break;
                 case 'thirdImage':
                     $basePath .= 'thirdimage/';
                     break;
                 case 'firstFile':
                     $basePath .= 'firstfile/';
                     break;
                 case 'secondFile':
                     $basePath .= 'secondfile/';
                     break;
                 case 'thirdFile':
                     $basePath .= 'thirdfile/';
                     break;
             }
             break;
         case 'rank':
             $basePath .= 'ranks/uploadimage/';
             break;
     }
     return $basePath;
 }
 public function getUploadRootDir()
 {
     return \FileUtil::getDataDirectory() . '/kmgallery/media';
 }