コード例 #1
0
ファイル: playjoom.php プロジェクト: TFToto/playjoom-builds
 /**
  * Method for create a path for PlayJoom functions
  *
  * @return string absolute path definition for PlayJoom.
  */
 public static function getPJPath()
 {
     $params = JComponentHelper::getParams('com_playjoom');
     $dispatcher = JDispatcher::getInstance();
     // Get the user objects
     $user = JFactory::getUser();
     $path = $params->get('file_path', JPATH_SITE);
     //$dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__.":".__LINE__, 'message' => 'Set path '.$path, 'priority' => JLog::INFO, 'section' => 'admin')));
     // Set the path definitions
     if ($params->get('user_folder', 0) == 1 && !JAccess::check($user->get('id'), 'core.admin') == 1) {
         $userbase = PlayJoomHelper::checkFolderPath($path);
         //Get name for user folder
         //Filter folder name for not allowed characters
         $filterArray = array("/%/", "/'/", "/\$/", "/</", "/>/", "/\"/", "/\\*/", "/&/", "/=/");
         $replaceArray = array(null, null, null, null, null, null, null, null, null);
         $UserFolder = preg_replace($filterArray, $replaceArray, $user->get('username'));
         //Check if user folder exists
         if (is_dir($userbase . DIRECTORY_SEPARATOR . $UserFolder)) {
             $PJpath = $params->get('file_path', JPATH_SITE) . DIRECTORY_SEPARATOR . $UserFolder;
         } else {
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'User folder does not exists for path: ' . $path . DIRECTORY_SEPARATOR . $UserFolder, 'priority' => JLog::WARNING, 'section' => 'admin')));
             jimport('joomla.filesystem.file');
             jimport('joomla.filesystem.folder');
             JFolder::create($userbase . DIRECTORY_SEPARATOR . $UserFolder);
             $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
             JFile::write($userbase . DIRECTORY_SEPARATOR . $UserFolder . "/index.html", $data);
             if (!is_dir($userbase . DIRECTORY_SEPARATOR . $UserFolder)) {
                 $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'User folder can not create with path: ' . $path . DIRECTORY_SEPARATOR . $UserFolder, 'priority' => JLog::WARNING, 'section' => 'admin')));
                 $PJpath = null;
             } else {
                 $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'User folder create compete', 'priority' => JLog::INFO, 'section' => 'admin')));
                 $PJpath = $userbase . DIRECTORY_SEPARATOR . $UserFolder;
             }
         }
     } else {
         $PJpath = PlayJoomHelper::checkFolderPath($path);
     }
     return $PJpath;
 }