Example #1
0
 public static function getInstance($identifier = 0)
 {
     // Find the user id
     if (empty($identifier) and function_exists('wp_get_current_user')) {
         $user = wp_get_current_user();
         $id = $user->ID;
     } else {
         if (!is_numeric($identifier)) {
             if (!($id = MUserHelper::getUserId($identifier))) {
                 MError::raiseWarning('SOME_ERROR_CODE', MText::sprintf('MLIB_USER_ERROR_ID_NOT_EXISTS', $identifier));
                 $retval = false;
                 return $retval;
             }
         } else {
             $id = $identifier;
         }
     }
     if (empty(self::$instances[$id])) {
         $user = new MUser($id);
         self::$instances[$id] = $user;
     }
     return self::$instances[$id];
 }
Example #2
0
 public static function isOwner($path)
 {
     mimport('framework.filesystem.file');
     $tmp = md5(MUserHelper::genRandomPassword(16));
     $ssp = ini_get('session.save_path');
     $jtp = MPATH_SITE . '/tmp';
     // Try to find a writable directory
     $dir = is_writable('/tmp') ? '/tmp' : false;
     $dir = !$dir && is_writable($ssp) ? $ssp : false;
     $dir = !$dir && is_writable($jtp) ? $jtp : false;
     if ($dir) {
         $test = $dir . '/' . $tmp;
         // Create the test file
         $blank = '';
         MFile::write($test, $blank, false);
         // Test ownership
         $return = fileowner($test) == fileowner($path);
         // Delete the test file
         MFile::delete($test);
         return $return;
     }
     return false;
 }