!C99Shell v. 1.0 pre-release build #13!

Software: Apache. PHP/5.5.15 

uname -a: Windows NT SVR-DMZ 6.1 build 7600 (Windows Server 2008 R2 Enterprise Edition) i586 

SYSTEM 

Safe-mode: OFF (not secure)

C:\dmz\php\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\NamingConventions\   drwxrwxrwx
Free 4.11 GB of 39.52 GB (10.39%)
Detected drives: [ a ] [ c ] [ d ] [ e ] [ f ]
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     UpperCaseConstantNameSniff.php (6.88 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
 * Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff.
 *
 * PHP version 5
 *
 * @category  PHP
 * @package   PHP_CodeSniffer
 * @author    Greg Sherwood <gsherwood@squiz.net>
 * @author    Marc McIntyre <mmcintyre@squiz.net>
 * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600)
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 */

/**
 * Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff.
 *
 * Ensures that constant names are all uppercase.
 *
 * @category  PHP
 * @package   PHP_CodeSniffer
 * @author    Greg Sherwood <gsherwood@squiz.net>
 * @author    Marc McIntyre <mmcintyre@squiz.net>
 * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600)
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
 * @version   Release: 1.3.3
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 */
class Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_CodeSniffer_Sniff
{


    
/**
     * Returns an array of tokens this test wants to listen for.
     *
     * @return array
     */
    
public function register()
    {
        return array(
T_STRING);

    }
//end register()


    /**
     * Processes this test, when one of its tokens is encountered.
     *
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
     * @param int                  $stackPtr  The position of the current token in the
     *                                        stack passed in $tokens.
     *
     * @return void
     */
    
public function process(PHP_CodeSniffer_File $phpcsFile$stackPtr)
    {
        
$tokens    $phpcsFile->getTokens();
        
$constName $tokens[$stackPtr]['content'];

        
// If this token is in a heredoc, ignore it.
        
if ($phpcsFile->hasCondition($stackPtrT_START_HEREDOC) === true) {
            return;
        }

        
// Special case for PHPUnit.
        
if ($constName === 'PHPUnit_MAIN_METHOD') {
            return;
        }

        
// If the next non-whitespace token after this token
        // is not an opening parenthesis then it is not a function call.
        
$openBracket $phpcsFile->findNext(T_WHITESPACE, ($stackPtr 1), nulltrue);
        if (
$tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
            
$functionKeyword $phpcsFile->findPrevious(array(T_WHITESPACET_COMMAT_COMMENTT_STRINGT_NS_SEPARATOR), ($stackPtr 1), nulltrue);

            
$declarations = array(
                             
T_FUNCTION,
                             
T_CLASS,
                             
T_INTERFACE,
                             
T_IMPLEMENTS,
                             
T_EXTENDS,
                             
T_INSTANCEOF,
                             
T_NEW,
                             
T_NAMESPACE,
                             
T_USE,
                             
T_AS,
                            );

            if (
in_array($tokens[$functionKeyword]['code'], $declarations) === true) {
                
// This is just a declaration; no constants here.
                
return;
            }

            if (
$tokens[$functionKeyword]['code'] === T_CONST) {
                
// This is a class constant.
                
if (strtoupper($constName) !== $constName) {
                    
$error 'Class constants must be uppercase; expected %s but found %s';
                    
$data  = array(
                              
strtoupper($constName),
                              
$constName,
                             );
                    
$phpcsFile->addError($error$stackPtr'ClassConstantNotUpperCase'$data);
                }

                return;
            }

            
// Is this a class name?
            
$nextPtr $phpcsFile->findNext(T_WHITESPACE, ($stackPtr 1), nulltrue);
            if (
$tokens[$nextPtr]['code'] === T_DOUBLE_COLON) {
                return;
            }

            
// Is this a namespace name?
            
if ($tokens[$nextPtr]['code'] === T_NS_SEPARATOR) {
                return;
            }

            
// Is this a type hint?
            
if ($tokens[$nextPtr]['code'] === T_VARIABLE
                
|| $phpcsFile->isReference($nextPtr) === true
            
) {
                return;
            }

            
// Is this a member var name?
            
$prevPtr $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr 1), nulltrue);
            if (
$tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) {
                return;
            }

            
// Is this a namespace name?
            
if ($tokens[$prevPtr]['code'] === T_NS_SEPARATOR) {
                return;
            }

            
// Is this an instance of declare()
            
$prevPtr $phpcsFile->findPrevious(array(T_WHITESPACET_OPEN_PARENTHESIS), ($stackPtr 1), nulltrue);
            if (
$tokens[$prevPtr]['code'] === T_DECLARE) {
                return;
            }

            
// This is a real constant.
            
if (strtoupper($constName) !== $constName) {
                
$error 'Constants must be uppercase; expected %s but found %s';
                
$data  = array(
                          
strtoupper($constName),
                          
$constName,
                         );
                
$phpcsFile->addError($error$stackPtr'ConstantNotUpperCase'$data);
            }

        } else if (
strtolower($constName) === 'define' || strtolower($constName) === 'constant') {

            
/*
                This may be a "define" or "constant" function call.
            */

            // Make sure this is not a method call.
            
$prev $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr 1), nulltrue);
            if (
$tokens[$prev]['code'] === T_OBJECT_OPERATOR
                
|| $tokens[$prev]['code'] === T_DOUBLE_COLON
            
) {
                return;
            }

            
// The next non-whitespace token must be the constant name.
            
$constPtr $phpcsFile->findNext(T_WHITESPACE, ($openBracket 1), nulltrue);
            if (
$tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) {
                return;
            }

            
$constName $tokens[$constPtr]['content'];

            
// Check for constants like self::CONSTANT.
            
$prefix   '';
            
$splitPos strpos($constName'::');
            if (
$splitPos !== false) {
                
$prefix    substr($constName0, ($splitPos 2));
                
$constName substr($constName, ($splitPos 2));
            }

            if (
strtoupper($constName) !== $constName) {
                
$error 'Constants must be uppercase; expected %s but found %s';
                
$data  = array(
                          
$prefix.strtoupper($constName),
                          
$prefix.$constName,
                         );
                
$phpcsFile->addError($error$stackPtr'ConstantNotUpperCase'$data);
            }
        }
//end if

    
}//end process()


}//end class

?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0156 ]--