<?php
/**
 * Tracking Bag
 */
namespace Omniship\Common;

use Omniship\Helper\Collection;
use Omniship\Interfaces\TrackingInterface;

/**
 * Shipping Tracking Multiple Bag
 *
 * This class defines a bag (multi element set or array) of single shipping items
 * in the Omniship system.
 *
 * @see Item
 */
class TrackingMultipleBag extends Collection
{

    /**
     * Create a new collection.
     *
     * @param  mixed  $items
     */
    public function __construct($items = [])
    {
        $items = array_map(function($item) {
            return !($item instanceof TrackingBag) ? new TrackingBag($item) : $item;
        }, $items);
        parent::__construct($items);
    }

    /**
     * Set the item at a given offset.
     *
     * @param  mixed  $key
     * @param  mixed  $value
     * @return void
     */
    public function offsetSet($key, $value)
    {
        if(!($value instanceof TrackingBag)) {
            $value = new TrackingBag($value);
        }
        parent::offsetSet($key, $value);
    }

    /**
     * Get all of the items in the collection.
     *
     * @return TrackingBag[]
     */
    public function all()
    {
        return parent::all();
    }
}


<?php

namespace PhpOffice\PhpSpreadsheet\Shared\OLE;

use PhpOffice\PhpSpreadsheet\Shared\OLE;

class ChainedBlockStream
{
    /**
     * The OLE container of the file that is being read.
     *
     * @var OLE
     */
    public $ole;

    /**
     * Parameters specified by fopen().
     *
     * @var array
     */
    public $params;

    /**
     * The binary data of the file.
     *
     * @var string
     */
    public $data;

    /**
     * The file pointer.
     *
     * @var int byte offset
     */
    public $pos;

    /**
     * Implements support for fopen().
     * For creating streams using this wrapper, use OLE_PPS_File::getStream().
     *
     * @param string $path resource name including scheme, e.g.
     *                                    ole-chainedblockstream://oleInstanceId=1
     * @param string $mode only "r" is supported
     * @param int $options mask of STREAM_REPORT_ERRORS and STREAM_USE_PATH
     * @param string &$openedPath absolute path of the opened stream (out parameter)
     *
     * @return bool true on success
     */
    public function stream_open($path, $mode, $options, &$openedPath) // @codingStandardsIgnoreLine
    {
        if ($mode != 'r') {
            if ($options & STREAM_REPORT_ERRORS) {
                trigger_error('Only reading is supported', E_USER_WARNING);
            }

            return false;
        }

        // 25 is length of "ole-chainedblockstream://"
        parse_str(substr($path, 25), $this->params);
        if (!isset($this->params['oleInstanceId'], $this->params['blockId'], $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
            if ($options & STREAM_REPORT_ERRORS) {
                trigger_error('OLE stream not found', E_USER_WARNING);
            }

            return false;
        }
        $this->ole = $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']];

        $blockId = $this->params['blockId'];
        $this->data = '';
        if (isset($this->params['size']) && $this->params['size'] < $this->ole->bigBlockThreshold && $blockId != $this->ole->root->startBlock) {
            // Block id refers to small blocks
            $rootPos = $this->ole->_getBlockOffset($this->ole->root->startBlock);
            while ($blockId != -2) {
                $pos = $rootPos + $blockId * $this->ole->bigBlockSize;
                $blockId = $this->ole->sbat[$blockId];
                fseek($this->ole->_file_handle, $pos);
                $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
            }
        } else {
            // Block id refers to big blocks
            while ($blockId != -2) {
                $pos = $this->ole->_getBlockOffset($blockId);
                fseek($this->ole->_file_handle, $pos);
                $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
                $blockId = $this->ole->bbat[$blockId];
            }
        }
        if (isset($this->params['size'])) {
            $this->data = substr($this->data, 0, $this->params['size']);
        }

        if ($options & STREAM_USE_PATH) {
            $openedPath = $path;
        }

        return true;
    }

    /**
     * Implements support for fclose().
     */
    public function stream_close() // @codingStandardsIgnoreLine
    {
        $this->ole = null;
        unset($GLOBALS['_OLE_INSTANCES']);
    }

    /**
     * Implements support for fread(), fgets() etc.
     *
     * @param int $count maximum number of bytes to read
     *
     * @return string
     */
    public function stream_read($count) // @codingStandardsIgnoreLine
    {
        if ($this->stream_eof()) {
            return false;
        }
        $s = substr($this->data, $this->pos, $count);
        $this->pos += $count;

        return $s;
    }

    /**
     * Implements support for feof().
     *
     * @return bool TRUE if the file pointer is at EOF; otherwise FALSE
     */
    public function stream_eof() // @codingStandardsIgnoreLine
    {
        return $this->pos >= strlen($this->data);
    }

    /**
     * Returns the position of the file pointer, i.e. its offset into the file
     * stream. Implements support for ftell().
     *
     * @return int
     */
    public function stream_tell() // @codingStandardsIgnoreLine
    {
        return $this->pos;
    }

    /**
     * Implements support for fseek().
     *
     * @param int $offset byte offset
     * @param int $whence SEEK_SET, SEEK_CUR or SEEK_END
     *
     * @return bool
     */
    public function stream_seek($offset, $whence) // @codingStandardsIgnoreLine
    {
        if ($whence == SEEK_SET && $offset >= 0) {
            $this->pos = $offset;
        } elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
            $this->pos += $offset;
        } elseif ($whence == SEEK_END && -$offset <= count($this->data)) {
            $this->pos = strlen($this->data) + $offset;
        } else {
            return false;
        }

        return true;
    }

    /**
     * Implements support for fstat(). Currently the only supported field is
     * "size".
     *
     * @return array
     */
    public function stream_stat() // @codingStandardsIgnoreLine
    {
        return [
            'size' => strlen($this->data),
            ];
    }

    // Methods used by stream_wrapper_register() that are not implemented:
    // bool stream_flush ( void )
    // int stream_write ( string data )
    // bool rename ( string path_from, string path_to )
    // bool mkdir ( string path, int mode, int options )
    // bool rmdir ( string path, int options )
    // bool dir_opendir ( string path, int options )
    // array url_stat ( string path, int flags )
    // string dir_readdir ( void )
    // bool dir_rewinddir ( void )
    // bool dir_closedir ( void )
}


<?php
/*   _            _          _ ____   ___  _____
 *  | |          | |        | |___ \ / _ \| ____|
 *  | |      __ _| |__   ___| | __) | | | | |__
 *  | |     / _` | '_ \ / _ \ ||__ <|  -  |___ \
 *  | |____| (_| | |_) |  __/ |___) |     |___) |
 *  |______|\__,_|_.__/ \___|_|____/ \___/|____/
 *
 *  Copyright Label305 B.V. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Label305\AujaLaravel;

use Illuminate\Foundation\Application;
use Illuminate\Pagination\Paginator;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Log;
use Label305\Auja\Main\Item;
use Label305\Auja\Main\Main;
use Label305\Auja\Menu\Menu;
use Label305\Auja\Page\Form;
use Label305\AujaLaravel\Config\AujaConfigurator;
use Label305\AujaLaravel\Config\Model;
use Label305\AujaLaravel\Config\ModelConfig;
use Label305\AujaLaravel\Config\Relation;
use Label305\AujaLaravel\Factory\AssociationMenuFactory;
use Label305\AujaLaravel\Factory\AuthenticationFormFactory;
use Label305\AujaLaravel\Factory\MainFactory;
use Label305\AujaLaravel\Factory\MultipleAssociationsIndexMenuFactory;
use Label305\AujaLaravel\Factory\NoAssociationsIndexMenuFactory;
use Label305\AujaLaravel\Factory\PageFactory;
use Label305\AujaLaravel\Factory\ResourceItemsFactory;
use Label305\AujaLaravel\Factory\SingleAssociationIndexMenuFactory;
use Illuminate\Database\Eloquent\Model as Eloquent;

/**
 * The main class to interact with.
 * This class can generate all necessary menus and pages, as well as the main page.
 *
 * Prior to interacting with other functions in this class, call Auja::init($modelNames).
 *
 * @author  Niek Haarman - <niek@label305.com>
 *
 * @package Label305\AujaLaravel
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */
class Auja {

    /**
     * @var Application The Application instance.
     */
    private $app;

    /**
     * @var AujaConfigurator
     */
    private $aujaConfigurator;

    /**
     * Creates a new Auja instance.
     *
     * @param Application $app The Illuminate Application instance.
     * @param AujaConfigurator $aujaConfigurator
     * @param [] $models The model configuration.
     */
    function __construct(Application $app, AujaConfigurator $aujaConfigurator, array $modelNames) {
        if (php_sapi_name() == 'cli') {
            /* Don't run when we're running artisan commands. */
            return;
        }

        if (empty($modelNames)) {
            throw new \InvalidArgumentException('Provide models for Auja to manage');
        }

        $this->app = $app;

        Log::debug('Initializing Auja with models:', $modelNames);

        $this->aujaConfigurator = $aujaConfigurator;
        $this->aujaConfigurator->configure($modelNames);
    }

    /**
     * @return Model[] the array of Model instances.
     */
    public function getModels() {
        return $this->aujaConfigurator->getModels();
    }

    /**
     * @param String $modelName The name of the model.
     *
     * @return Model The `Model` with given name.
     */
    public function getModel($modelName) {
        return $this->aujaConfigurator->getModel($modelName);
    }

    /**
     * @param Model $model The `Model` to get relations for.
     *
     * @return Config\Relation[] The `Relation`s for given `Model`.
     */
    public function getRelationsForModel(Model $model) {
        return $this->aujaConfigurator->getRelationsForModel($model);
    }

    /**
     * Creates a default authentication `Form` to be used in a `Main` instance.
     *
     * @param String $title  The title to display.
     * @param String $target The target url to post to when logging in.
     *
     * @return Form The authentication `Form`.
     */
    public function authenticationForm($title, $target) {
        $formFactory = $this->app->make('Label305\AujaLaravel\Factory\AuthenticationFormFactory');
        /* @var $formFactory AuthenticationFormFactory */
        return $formFactory->create($title, $target);
    }

    /**
     * Creates the initial Auja view based on the models as initialized in init().
     *
     * @param String        $title                  The title to show.
     * @param boolean       $authenticated          Whether the user is authenticated.
     * @param String        $username               (optional) The user name to show.
     * @param String        $logoutTarget           (optional) The target url for logging out.
     * @param Form          $authenticationForm     (optional) The `Form` to use for authentication, or `null` if none.
     * @param ModelConfig   $config                 (optional) The `ModelConfig` to use.
     * @param Item[]|null   $additionalMenuItems    (optional) Enter an array of additional Label305\Auja\Main\Item
     *                                              objects to display as main tabs.
     * @param bool          $smartMenuItemInclude   (optional) Enter false to disable all the auto inclusion of menu
     *                                              items for models, you can also set a per model auto inclusion
     *                                              property on a ModelConfig object
     *
     * @return Main the Main instance which can be configured further.
     */
    public function main($title, $authenticated, $username = null, $logoutTarget = null, Form $authenticationForm = null, ModelConfig $config = null, $additionalMenuItems = null, $smartMenuItemInclude = true) {
        $mainFactory = $this->app->make('Label305\AujaLaravel\Factory\MainFactory');
        /* @var $mainFactory MainFactory */
        return $mainFactory->create($title, $authenticated, $username, $logoutTarget, $authenticationForm, $config, $additionalMenuItems, $smartMenuItemInclude);
    }

    /**
     * Intelligently creates an index menu for given model, and optionally model id.
     *
     * @param Controller|Eloquent|String $model   An object which represents the model to build the menu for.
     * @param int                        $modelId (optional) The id of an instance of the model.
     * @param ModelConfig                $config  (optional) The `ModelConfig` to use.
     *
     * @return Menu The built `Menu` instance, which can be configured further.
     */
    public function menuFor($model, $modelId = 0, ModelConfig $config = null) {
        if (is_null($this->aujaConfigurator)) {
            throw new \LogicException('Auja not initialized. Call Auja::init first.');
        }

        $modelName = $this->resolveModelName($model);

        if ($modelId == 0) {
            $menu = $this->noAssociationsMenuFor($modelName, $config);
        } else {
            $menu = $this->buildComplexIndexMenu($modelName, $modelId, $config);
        }

        return $menu;
    }

    /**
     * Creates a `Menu` for given model, with a layout depending on its relations.
     *
     * @param String      $modelName The name of the model to create a `Menu` for.
     * @param int         $modelId   The id of an instance of the model, 0 for none.
     * @param ModelConfig $config    (optional) The `ModelConfig` to use.
     *
     * @return Menu The built `Menu` instance, which can be configured further.
     */
    private function buildComplexIndexMenu($modelName, $modelId, ModelConfig $config = null) {
        $model = $this->aujaConfigurator->getModel($modelName);
        $relations = $this->aujaConfigurator->getRelationsForModel($model);

        $associationRelations = array();
        foreach ($relations as $relation) {
            if ($relation->getType() == Relation::HAS_MANY || $relation->getType() == Relation::HAS_AND_BELONGS_TO) { // TODO: What to do with one-to-one relations?
                $associationRelations[] = $relation;
            }
        }

        switch (count($associationRelations)) {
            case 0:
                $menu = $this->noAssociationsMenuFor($modelName, $config);
                break;
            case 1:
                $menu = $this->singleAssociationMenuFor($modelName, $modelId, $associationRelations[0], $config);
                break;
            default:
                $menu = $this->multipleAssociationsMenuFor($modelName, $modelId, $associationRelations, $config);
                break;
        }

        return $menu;
    }

    /**
     * Builds a Resource instance for given model.
     * This is typically used when a ResourceMenuItem triggers a call for items.
     *
     * This method also supports pagination, either manually or automatically.
     * To automatically use pagination, simply provide a Paginator as items.
     *
     * @param Controller|Eloquent|String $model       An object which represents the model to build items for.
     * @param array|Paginator            $items       An array of instances of the model to be shown, or a Paginator containing the instances.
     * @param String                     $targetUrl   (optional) The target url for the items. Must contain '%d' in the place of the item id.
     * @param String                     $nextPageUrl (optional) The url to the next page, if any.
     * @param int                        $offset      (optional) The offset to start the order from.
     * @param ModelConfig                $config      (optional) The `ModelConfig` to use.
     *
     * @return Resource The built LinkMenuItems.
     */
    public function itemsFor($model, $items = null, $targetUrl = null, $nextPageUrl = null, $offset = -1, ModelConfig $config = null) {
        $modelName = $this->resolveModelName($model);

        if ($items == null) {
            $items = call_user_func(array($modelName, 'simplePaginate'), 10);
        }

        $factory = $this->app->make('Label305\AujaLaravel\Factory\ResourceItemsFactory');
        /* @var $factory ResourceItemsFactory */
        return $factory->create($modelName, $items, $targetUrl, $nextPageUrl, $offset, $config);
    }

    /**
     * Creates a simple menu for given model, where typically this model should not have any relations to other models.
     *
     * The menu will include:
     *  - An Add LinkMenuItem;
     *  - A SpacerMenuItem with the model's name;
     *  - A ResourceMenuItem to hold entries of the model.
     *
     * @param Controller|Eloquent|String $model  An object which represents the model to build items for.
     * @param ModelConfig                $config (optional) The `ModelConfig` to use.
     *
     * @return Menu The `Menu`, which can be configured further.
     */
    public function noAssociationsMenuFor($model, ModelConfig $config = null) {
        $modelName = $this->resolveModelName($model);

        $menuFactory = $this->app->make('Label305\AujaLaravel\Factory\NoAssociationsIndexMenuFactory');
        /* @var $menuFactory NoAssociationsIndexMenuFactory */
        return $menuFactory->create($modelName, $config);
    }

    /**
     * Builds a menu for a single model entry, where the model has exactly one relationship with another model.
     *
     * The menu will include:
     *  - An Edit LinkMenuItem;
     *  - A SpacerMenuItem with the name of the associated model;
     *  - A ResourceMenuItem to hold entries of the associated model.
     *
     * @param Controller|Eloquent|String $model    An object which represents the model to build items for.
     * @param int                        $modelId  The id of the model entry.
     * @param Relation                   $relation The Relation this model has with the associated model.
     * @param ModelConfig                $config   (optional) The `ModelConfig` to use.
     *
     * @return Menu the `Menu`, which can be configured further.
     */
    public function singleAssociationMenuFor($model, $modelId, Relation $relation, ModelConfig $config = null) {
        $modelName = $this->resolveModelName($model);

        $menuFactory = $this->app->make('Label305\AujaLaravel\Factory\SingleAssociationIndexMenuFactory');
        /* @var $menuFactory SingleAssociationIndexMenuFactory */
        return $menuFactory->create($modelName, $modelId, $relation, $config);
    }

    /**
     * Builds a menu for a single model entry, where the model has multiple relationships with other models.
     *
     * The menu will include:
     *  - An Edit LinkMenuItem;
     *  - For each of the Relations, a LinkMenuItem for the associated model.
     *
     * @param Controller|Eloquent|String $model     An object which represents the model to build items for.
     * @param int                        $modelId   The id of the model entry.
     * @param Relation[]                 $relations The `Relation`s this model has with associated models.
     * @param ModelConfig                $config    (optional) The `ModelConfig` to use.
     *
     * @return Menu the Menu, which can be configured further.
     */
    public function multipleAssociationsMenuFor($model, $modelId, array $relations, ModelConfig $config = null) {
        $modelName = $this->resolveModelName($model);

        $menuFactory = $this->app->make('Label305\AujaLaravel\Factory\MultipleAssociationsIndexMenuFactory');
        /* @var $menuFactory MultipleAssociationsIndexMenuFactory */
        return $menuFactory->create($modelName, $modelId, $relations, $config);
    }

    /**
     * Builds a menu for displaying associated items to a model entry (i.e. /club/21/team).
     *
     * The menu will include:
     *  - An Add LinkMenuItem;
     *  - A SpacerMenuItem with the name of the associated model;
     *  - A ResourceMenuItem to hold entries of the associated model.
     *
     * @param String      $modelName       The name of the model (i.e. Club).
     * @param int         $modelId         The id of the model entry.
     * @param String      $associationName The name of the associated model (i.e. Team).
     * @param ModelConfig $config          (optional) The `ModelConfig` to use.
     *
     * @return Menu the Menu, which can be configured further.
     */
    public function associationMenuFor($modelName, $modelId, $associationName, ModelConfig $config = null) {
        $menuFactory = $this->app->make('Label305\AujaLaravel\Factory\AssociationMenuFactory');
        /* @var $menuFactory AssociationMenuFactory */
        return $menuFactory->create($modelName, $modelId, $associationName, $config);
    }

    /**
     * Creates a Page for given model.
     *
     * @param Controller|Eloquent|String $model  An object which represents the model to build items for.
     * @param int                        $itemId (optional) The id of an instance of the model.
     * @param ModelConfig                $config (optional) The `ModelConfig` to use.
     *
     * @return \Label305\Auja\Page\Page The created Page
     */
    public function pageFor($model, $itemId = 0, ModelConfig $config = null) {
        $modelName = $this->resolveModelName($model);
        $item = $this->findItem($modelName, $itemId);

        $pageFactory = $this->app->make('Label305\AujaLaravel\Factory\PageFactory');
        /* @var $pageFactory PageFactory */
        return $pageFactory->create($modelName, $item, $config);
    }

    /**
     * Uses Eloquent::find($id) to find the item matching given id, if available.
     *
     * @param String $modelName The name of the model.
     * @param int    $itemId    The id of the instance of the model to find.
     *
     * @return Eloquent The model instance, or null if none.
     */
    private function findItem($modelName, $itemId) {
        return $itemId = 0 ? null : call_user_func(array($modelName, 'find'), $itemId);
    }

    /**
     * Resolves the model name.
     *
     * @param Controller|Eloquent|String $model An object which represents the model.
     *
     * @return String the model name.
     */
    private function resolveModelName($model) {
        if ($model instanceof Controller) {
            $exploded = explode('\\', get_class($model));
            $controllerName = array_pop($exploded);
            return str_singular(str_replace('Controller', '', $controllerName));
        } else if ($model instanceof Eloquent) {
            return get_class($model);
        } else {
            return $model;
        }
    }
}


<?php
/**
 * Custom Images Grifus · Extensions For Grifus
 *
 * @author    Josantonius <hello@josantonius.com>
 * @package   eliasis-framework/custom-images-grifus
 * @copyright 2017 - 2018 (c) Josantonius - Custom Images Grifus
 * @license   GPL-2.0+
 * @link      https://github.com/eliasis-framework/custom-images-grifus.git
 * @since     1.0.0
 */

namespace EFG\Modules\CustomImagesGrifus\Controller;

use Eliasis\Complement\Type\Module;
use Eliasis\Framework\Controller;
use Eliasis\Framework\App;

/**
 * Module main controller.
 */
class Launcher extends Controller {

	/**
	 * Class initializer method.
	 */
	public function init() {

		$state = Module::CustomImagesGrifus()->getOption( 'state' );

		if ( 'active' === $state || 'outdated' === $state ) {
			if ( is_admin() ) {
				App::setCurrentID( 'EFG' );
				$this->admin();
			}
		}
	}

	/**
	 * Module activation hook. Executed when module is activated.
	 *
	 * @since 1.0.1
	 */
	public function activation() {

		$this->model->add_options();
	}

	/**
	 * Module uninstallation hook. Executed when module is uninstalled.
	 */
	public function uninstallation() {

		$this->model->delete_post_meta();
		$this->model->delete_options();
	}

	/**
	 * Admin initializer method.
	 *
	 * @uses add_action() → hooks a function on to a specific action
	 */
	public function admin() {

		$this->set_options();

		add_action( 'init', [ $this, 'set_language' ] );

		$namespace = Module::CustomImagesGrifus()->getOption( 'namespaces' );
		$pages     = Module::CustomImagesGrifus()->getOption( 'pages' );
		App::main()->set_menus( $pages, $namespace['admin-page'] );
		$image = Module::CustomImagesGrifus()->getControllerInstance( 'Image' );

		add_action( 'wp_insert_post', [ $image, 'set_images' ], 10, 3 );
		add_action( 'before_delete_post', [ $image, 'delete_attached_images' ], 10, 1 );
	}

	/**
	 * Set database module options.
	 *
	 * @since 1.0.1
	 */
	public function set_options() {

		$slug    = Module::CustomImagesGrifus()->getOption( 'slug' );
		$options = $this->model->get_options();

		foreach ( $options as $option => $value ) {
			Module::CustomImagesGrifus()->setOption( $option, $value );
		}
	}

	/**
	 * Set plugin textdomain.
	 */
	public function set_language() {

		$plugin_slug = App::EFG()->getOption( 'slug' );
		$module_slug = Module::CustomImagesGrifus()->getOption( 'slug' );

		$path = $plugin_slug . '/modules/' . $module_slug . '/languages/';

		load_plugin_textdomain( $plugin_slug . '-images', false, $path );
	}
}


<?php

namespace PhpOffice\PhpSpreadsheet\Reader\Xls;

class MD5
{
    // Context
    private $a;

    private $b;

    private $c;

    private $d;

    /**
     * MD5 stream constructor.
     */
    public function __construct()
    {
        $this->reset();
    }

    /**
     * Reset the MD5 stream context.
     */
    public function reset()
    {
        $this->a = 0x67452301;
        $this->b = 0xEFCDAB89;
        $this->c = 0x98BADCFE;
        $this->d = 0x10325476;
    }

    /**
     * Get MD5 stream context.
     *
     * @return string
     */
    public function getContext()
    {
        $s = '';
        foreach (['a', 'b', 'c', 'd'] as $i) {
            $v = $this->{$i};
            $s .= chr($v & 0xff);
            $s .= chr(($v >> 8) & 0xff);
            $s .= chr(($v >> 16) & 0xff);
            $s .= chr(($v >> 24) & 0xff);
        }

        return $s;
    }

    /**
     * Add data to context.
     *
     * @param string $data Data to add
     */
    public function add($data)
    {
        $words = array_values(unpack('V16', $data));

        $A = $this->a;
        $B = $this->b;
        $C = $this->c;
        $D = $this->d;

        $F = ['self', 'f'];
        $G = ['self', 'g'];
        $H = ['self', 'h'];
        $I = ['self', 'i'];

        // ROUND 1
        self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
        self::step($F, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756);
        self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db);
        self::step($F, $B, $C, $D, $A, $words[3], 22, 0xc1bdceee);
        self::step($F, $A, $B, $C, $D, $words[4], 7, 0xf57c0faf);
        self::step($F, $D, $A, $B, $C, $words[5], 12, 0x4787c62a);
        self::step($F, $C, $D, $A, $B, $words[6], 17, 0xa8304613);
        self::step($F, $B, $C, $D, $A, $words[7], 22, 0xfd469501);
        self::step($F, $A, $B, $C, $D, $words[8], 7, 0x698098d8);
        self::step($F, $D, $A, $B, $C, $words[9], 12, 0x8b44f7af);
        self::step($F, $C, $D, $A, $B, $words[10], 17, 0xffff5bb1);
        self::step($F, $B, $C, $D, $A, $words[11], 22, 0x895cd7be);
        self::step($F, $A, $B, $C, $D, $words[12], 7, 0x6b901122);
        self::step($F, $D, $A, $B, $C, $words[13], 12, 0xfd987193);
        self::step($F, $C, $D, $A, $B, $words[14], 17, 0xa679438e);
        self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821);

        // ROUND 2
        self::step($G, $A, $B, $C, $D, $words[1], 5, 0xf61e2562);
        self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340);
        self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51);
        self::step($G, $B, $C, $D, $A, $words[0], 20, 0xe9b6c7aa);
        self::step($G, $A, $B, $C, $D, $words[5], 5, 0xd62f105d);
        self::step($G, $D, $A, $B, $C, $words[10], 9, 0x02441453);
        self::step($G, $C, $D, $A, $B, $words[15], 14, 0xd8a1e681);
        self::step($G, $B, $C, $D, $A, $words[4], 20, 0xe7d3fbc8);
        self::step($G, $A, $B, $C, $D, $words[9], 5, 0x21e1cde6);
        self::step($G, $D, $A, $B, $C, $words[14], 9, 0xc33707d6);
        self::step($G, $C, $D, $A, $B, $words[3], 14, 0xf4d50d87);
        self::step($G, $B, $C, $D, $A, $words[8], 20, 0x455a14ed);
        self::step($G, $A, $B, $C, $D, $words[13], 5, 0xa9e3e905);
        self::step($G, $D, $A, $B, $C, $words[2], 9, 0xfcefa3f8);
        self::step($G, $C, $D, $A, $B, $words[7], 14, 0x676f02d9);
        self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a);

        // ROUND 3
        self::step($H, $A, $B, $C, $D, $words[5], 4, 0xfffa3942);
        self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681);
        self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122);
        self::step($H, $B, $C, $D, $A, $words[14], 23, 0xfde5380c);
        self::step($H, $A, $B, $C, $D, $words[1], 4, 0xa4beea44);
        self::step($H, $D, $A, $B, $C, $words[4], 11, 0x4bdecfa9);
        self::step($H, $C, $D, $A, $B, $words[7], 16, 0xf6bb4b60);
        self::step($H, $B, $C, $D, $A, $words[10], 23, 0xbebfbc70);
        self::step($H, $A, $B, $C, $D, $words[13], 4, 0x289b7ec6);
        self::step($H, $D, $A, $B, $C, $words[0], 11, 0xeaa127fa);
        self::step($H, $C, $D, $A, $B, $words[3], 16, 0xd4ef3085);
        self::step($H, $B, $C, $D, $A, $words[6], 23, 0x04881d05);
        self::step($H, $A, $B, $C, $D, $words[9], 4, 0xd9d4d039);
        self::step($H, $D, $A, $B, $C, $words[12], 11, 0xe6db99e5);
        self::step($H, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8);
        self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665);

        // ROUND 4
        self::step($I, $A, $B, $C, $D, $words[0], 6, 0xf4292244);
        self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97);
        self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7);
        self::step($I, $B, $C, $D, $A, $words[5], 21, 0xfc93a039);
        self::step($I, $A, $B, $C, $D, $words[12], 6, 0x655b59c3);
        self::step($I, $D, $A, $B, $C, $words[3], 10, 0x8f0ccc92);
        self::step($I, $C, $D, $A, $B, $words[10], 15, 0xffeff47d);
        self::step($I, $B, $C, $D, $A, $words[1], 21, 0x85845dd1);
        self::step($I, $A, $B, $C, $D, $words[8], 6, 0x6fa87e4f);
        self::step($I, $D, $A, $B, $C, $words[15], 10, 0xfe2ce6e0);
        self::step($I, $C, $D, $A, $B, $words[6], 15, 0xa3014314);
        self::step($I, $B, $C, $D, $A, $words[13], 21, 0x4e0811a1);
        self::step($I, $A, $B, $C, $D, $words[4], 6, 0xf7537e82);
        self::step($I, $D, $A, $B, $C, $words[11], 10, 0xbd3af235);
        self::step($I, $C, $D, $A, $B, $words[2], 15, 0x2ad7d2bb);
        self::step($I, $B, $C, $D, $A, $words[9], 21, 0xeb86d391);

        $this->a = ($this->a + $A) & 0xffffffff;
        $this->b = ($this->b + $B) & 0xffffffff;
        $this->c = ($this->c + $C) & 0xffffffff;
        $this->d = ($this->d + $D) & 0xffffffff;
    }

    private static function f($X, $Y, $Z)
    {
        return ($X & $Y) | ((~$X) & $Z); // X AND Y OR NOT X AND Z
    }

    private static function g($X, $Y, $Z)
    {
        return ($X & $Z) | ($Y & (~$Z)); // X AND Z OR Y AND NOT Z
    }

    private static function h($X, $Y, $Z)
    {
        return $X ^ $Y ^ $Z; // X XOR Y XOR Z
    }

    private static function i($X, $Y, $Z)
    {
        return $Y ^ ($X | (~$Z)); // Y XOR (X OR NOT Z)
    }

    private static function step($func, &$A, $B, $C, $D, $M, $s, $t)
    {
        $A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
        $A = self::rotate($A, $s);
        $A = ($B + $A) & 0xffffffff;
    }

    private static function rotate($decimal, $bits)
    {
        $binary = str_pad(decbin($decimal), 32, '0', STR_PAD_LEFT);

        return bindec(substr($binary, $bits) . substr($binary, 0, $bits));
    }
}


<?php

namespace PhpOffice\PhpSpreadsheet\Writer\Ods;

use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;

class Meta extends WriterPart
{
    /**
     * Write meta.xml to XML format.
     *
     * @param Spreadsheet $spreadsheet
     *
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
     *
     * @return string XML Output
     */
    public function write(Spreadsheet $spreadsheet = null)
    {
        if (!$spreadsheet) {
            $spreadsheet = $this->getParentWriter()->getSpreadsheet();
        }

        $objWriter = null;
        if ($this->getParentWriter()->getUseDiskCaching()) {
            $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
        } else {
            $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
        }

        // XML header
        $objWriter->startDocument('1.0', 'UTF-8');

        // Meta
        $objWriter->startElement('office:document-meta');

        $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
        $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
        $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
        $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
        $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
        $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
        $objWriter->writeAttribute('office:version', '1.2');

        $objWriter->startElement('office:meta');

        $objWriter->writeElement('meta:initial-creator', $spreadsheet->getProperties()->getCreator());
        $objWriter->writeElement('dc:creator', $spreadsheet->getProperties()->getCreator());
        $objWriter->writeElement('meta:creation-date', date(DATE_W3C, $spreadsheet->getProperties()->getCreated()));
        $objWriter->writeElement('dc:date', date(DATE_W3C, $spreadsheet->getProperties()->getCreated()));
        $objWriter->writeElement('dc:title', $spreadsheet->getProperties()->getTitle());
        $objWriter->writeElement('dc:description', $spreadsheet->getProperties()->getDescription());
        $objWriter->writeElement('dc:subject', $spreadsheet->getProperties()->getSubject());
        $keywords = explode(' ', $spreadsheet->getProperties()->getKeywords());
        foreach ($keywords as $keyword) {
            $objWriter->writeElement('meta:keyword', $keyword);
        }

        //<meta:document-statistic meta:table-count="XXX" meta:cell-count="XXX" meta:object-count="XXX"/>
        $objWriter->startElement('meta:user-defined');
        $objWriter->writeAttribute('meta:name', 'Company');
        $objWriter->writeRaw($spreadsheet->getProperties()->getCompany());
        $objWriter->endElement();

        $objWriter->startElement('meta:user-defined');
        $objWriter->writeAttribute('meta:name', 'category');
        $objWriter->writeRaw($spreadsheet->getProperties()->getCategory());
        $objWriter->endElement();

        $objWriter->endElement();

        $objWriter->endElement();

        return $objWriter->getData();
    }
}


<?php

namespace PhpOffice\PhpSpreadsheet\Writer;

use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Spreadsheet;

class Csv extends BaseWriter
{
    /**
     * PhpSpreadsheet object.
     *
     * @var Spreadsheet
     */
    private $spreadsheet;

    /**
     * Delimiter.
     *
     * @var string
     */
    private $delimiter = ',';

    /**
     * Enclosure.
     *
     * @var string
     */
    private $enclosure = '"';

    /**
     * Line ending.
     *
     * @var string
     */
    private $lineEnding = PHP_EOL;

    /**
     * Sheet index to write.
     *
     * @var int
     */
    private $sheetIndex = 0;

    /**
     * Whether to write a BOM (for UTF8).
     *
     * @var bool
     */
    private $useBOM = false;

    /**
     * Whether to write a Separator line as the first line of the file
     *     sep=x.
     *
     * @var bool
     */
    private $includeSeparatorLine = false;

    /**
     * Whether to write a fully Excel compatible CSV file.
     *
     * @var bool
     */
    private $excelCompatibility = false;

    /**
     * Create a new CSV.
     *
     * @param Spreadsheet $spreadsheet Spreadsheet object
     */
    public function __construct(Spreadsheet $spreadsheet)
    {
        $this->spreadsheet = $spreadsheet;
    }

    /**
     * Save PhpSpreadsheet to file.
     *
     * @param string $pFilename
     *
     * @throws Exception
     */
    public function save($pFilename)
    {
        // Fetch sheet
        $sheet = $this->spreadsheet->getSheet($this->sheetIndex);

        $saveDebugLog = Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog();
        Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false);
        $saveArrayReturnType = Calculation::getArrayReturnType();
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);

        // Open file
        $fileHandle = fopen($pFilename, 'wb+');
        if ($fileHandle === false) {
            throw new Exception("Could not open file $pFilename for writing.");
        }

        if ($this->excelCompatibility) {
            $this->setUseBOM(true); //  Enforce UTF-8 BOM Header
            $this->setIncludeSeparatorLine(true); //  Set separator line
            $this->setEnclosure('"'); //  Set enclosure to "
            $this->setDelimiter(';'); //  Set delimiter to a semi-colon
            $this->setLineEnding("\r\n");
        }
        if ($this->useBOM) {
            // Write the UTF-8 BOM code if required
            fwrite($fileHandle, "\xEF\xBB\xBF");
        }
        if ($this->includeSeparatorLine) {
            // Write the separator line if required
            fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->lineEnding);
        }

        //    Identify the range that we need to extract from the worksheet
        $maxCol = $sheet->getHighestDataColumn();
        $maxRow = $sheet->getHighestDataRow();

        // Write rows to file
        for ($row = 1; $row <= $maxRow; ++$row) {
            // Convert the row to an array...
            $cellsArray = $sheet->rangeToArray('A' . $row . ':' . $maxCol . $row, '', $this->preCalculateFormulas);
            // ... and write to the file
            $this->writeLine($fileHandle, $cellsArray[0]);
        }

        // Close file
        fclose($fileHandle);

        Calculation::setArrayReturnType($saveArrayReturnType);
        Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
    }

    /**
     * Get delimiter.
     *
     * @return string
     */
    public function getDelimiter()
    {
        return $this->delimiter;
    }

    /**
     * Set delimiter.
     *
     * @param string $pValue Delimiter, defaults to ','
     *
     * @return CSV
     */
    public function setDelimiter($pValue)
    {
        $this->delimiter = $pValue;

        return $this;
    }

    /**
     * Get enclosure.
     *
     * @return string
     */
    public function getEnclosure()
    {
        return $this->enclosure;
    }

    /**
     * Set enclosure.
     *
     * @param string $pValue Enclosure, defaults to "
     *
     * @return CSV
     */
    public function setEnclosure($pValue)
    {
        if ($pValue == '') {
            $pValue = null;
        }
        $this->enclosure = $pValue;

        return $this;
    }

    /**
     * Get line ending.
     *
     * @return string
     */
    public function getLineEnding()
    {
        return $this->lineEnding;
    }

    /**
     * Set line ending.
     *
     * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
     *
     * @return CSV
     */
    public function setLineEnding($pValue)
    {
        $this->lineEnding = $pValue;

        return $this;
    }

    /**
     * Get whether BOM should be used.
     *
     * @return bool
     */
    public function getUseBOM()
    {
        return $this->useBOM;
    }

    /**
     * Set whether BOM should be used.
     *
     * @param bool $pValue Use UTF-8 byte-order mark? Defaults to false
     *
     * @return CSV
     */
    public function setUseBOM($pValue)
    {
        $this->useBOM = $pValue;

        return $this;
    }

    /**
     * Get whether a separator line should be included.
     *
     * @return bool
     */
    public function getIncludeSeparatorLine()
    {
        return $this->includeSeparatorLine;
    }

    /**
     * Set whether a separator line should be included as the first line of the file.
     *
     * @param bool $pValue Use separator line? Defaults to false
     *
     * @return CSV
     */
    public function setIncludeSeparatorLine($pValue)
    {
        $this->includeSeparatorLine = $pValue;

        return $this;
    }

    /**
     * Get whether the file should be saved with full Excel Compatibility.
     *
     * @return bool
     */
    public function getExcelCompatibility()
    {
        return $this->excelCompatibility;
    }

    /**
     * Set whether the file should be saved with full Excel Compatibility.
     *
     * @param bool $pValue Set the file to be written as a fully Excel compatible csv file
     *                                Note that this overrides other settings such as useBOM, enclosure and delimiter
     *
     * @return CSV
     */
    public function setExcelCompatibility($pValue)
    {
        $this->excelCompatibility = $pValue;

        return $this;
    }

    /**
     * Get sheet index.
     *
     * @return int
     */
    public function getSheetIndex()
    {
        return $this->sheetIndex;
    }

    /**
     * Set sheet index.
     *
     * @param int $pValue Sheet index
     *
     * @return CSV
     */
    public function setSheetIndex($pValue)
    {
        $this->sheetIndex = $pValue;

        return $this;
    }

    /**
     * Write line to CSV file.
     *
     * @param resource $pFileHandle PHP filehandle
     * @param array $pValues Array containing values in a row
     */
    private function writeLine($pFileHandle, array $pValues)
    {
        // No leading delimiter
        $writeDelimiter = false;

        // Build the line
        $line = '';

        foreach ($pValues as $element) {
            // Escape enclosures
            $element = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $element);

            // Add delimiter
            if ($writeDelimiter) {
                $line .= $this->delimiter;
            } else {
                $writeDelimiter = true;
            }

            // Add enclosed string
            $line .= $this->enclosure . $element . $this->enclosure;
        }

        // Add line ending
        $line .= $this->lineEnding;

        // Write to file
        fwrite($pFileHandle, $line);
    }
}


<?php

namespace App\Http\Controllers\IntoTheSource\Users;

use App\UserManager as User;
use App\Role;
use App\Http\Controllers\Controller;
use App\Http\Requests\UserRequest;
use Illuminate\Http\Request;

/**
 * Users controller
 * @package users
 * @author Gertjan Roke <groke@intothesource.com>
 */
class UsersController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        $users = User::all();
        $deletedUsers = User::onlyTrashed()->get();
        return view('intothesource.usersmanager.users.index', compact('users', 'deletedUsers'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        $roles = Role::lists('name', 'id');
        return view('intothesource.usersmanager.users.create', compact('roles'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  UserRequest  $request
     * @return Response
     */
    public function store(UserRequest $request)
    {
        $user = new User;
        $request['password'] = bcrypt($request->get('password'));
        $user = $user->create($request->only($user->getFillable()));
        $user->roles()->sync(collect($request->get('role'))->all());

        return redirect()->route('user.manager.index');
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        $user = User::findOrFail($id);
        $roles = Role::lists('name', 'id');
        return view('intothesource.usersmanager.users.edit', compact('user', 'roles'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  UserRequest  $request
     * @param  int  $id
     * @return Response
     */
    public function update(UserRequest $request, $id)
    {
        $user = User::findOrFail($id);
        if($request->get('password') && ( bcrypt($request->get('old_password')) == $user->password)) {
            $request['password'] = bcrypt($request->get('password'));
        } elseif(!$request->get('password')) {
            $request['password'] = $user->password;
        } else {
            return redirect()->back()->withInput()->withErrors(['password' => 'The given password is not correct.']);
        }
        $user->update($request->only($user->getFillable()));
        $user->roles()->sync(collect($request->get('role'))->all());

        return redirect()->route('user.manager.index');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        $user = User::findOrFail($id);
        $user->delete();
        return redirect()->route('user.manager.index');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function restore($id)
    {
        $user = User::onlyTrashed()->findOrFail($id);
        $user->restore();
        return redirect()->route('user.manager.index');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function permanentlyDestroy($id)
    {
        $user = User::onlyTrashed()->findOrFail($id);
        $user->forceDelete();
        return redirect()->route('user.manager.index');
    }
}


<?php
/*   _            _          _ ____   ___  _____
 *  | |          | |        | |___ \ / _ \| ____|
 *  | |      __ _| |__   ___| | __) | | | | |__
 *  | |     / _` | '_ \ / _ \ ||__ <|  -  |___ \
 *  | |____| (_| | |_) |  __/ |___) |     |___) |
 *  |______|\__,_|_.__/ \___|_|____/ \___/|____/
 *
 *  Copyright Label305 B.V. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Label305\AujaLaravel\Controllers;

use Illuminate\Foundation\Application;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Label305\Auja\Main\Main;
use Label305\Auja\Shared\Message;
use Label305\AujaLaravel\Auja;
use Label305\AujaLaravel\Controllers\Interfaces\SupportControllerInterface;

/**
 * Default controller to support basic Auja functions like authentication and creating the main interface.
 *
 * @author  Thijs Scheepers - <thijs@label305.com>
 *
 * @package Label305\AujaLaravel
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */
class DefaultSupportController extends Controller implements SupportControllerInterface {

    /**
     * @var Application
     */
	public $app;

    /**
     * @param Application $app
     * @param Auja $auja
     */
	public function __construct(Application $app) {
        $this->app = $app;
    }

    /**
     * Returns the HTML view in which the JavaScript is loaded for the auja interface.
     *
     * @return \Illuminate\Http\Response
     */
    public function index() {

        return $this->app['view']->make('auja-laravel::admin.index');
    }

    /**
     * Returns the Auja main manifest containing information about the login state, theme of the interface
     * and the tabs on the side bar.
     *
     * @return \Illuminate\Http\Response json response with the auja main manifest
     */
    public function main() {

        $config = $this->app['config']['auja'] ?: $this->app['config']['auja-laravel::config'];

        $authenticationForm = $this->app['auja']->authenticationForm(
            $config['title'],
            $this->app['url']->route('auja.support.login', [], false)
        );

        $username = ($this->app['auth']->user() == null) ? null : $this->app['auth']->user()->name;

        $main = $this->app['auja']->main(
            $config['title'],
            $this->app['auth']->check(),
        	$username,
            $this->app['url']->route('auja.support.logout', [], false),
        	$authenticationForm
        );

        $main->setColor(Main::COLOR_MAIN, $config['color']['main']);
        $main->setColor(Main::COLOR_ALERT, $config['color']['alert']);
        $main->setColor(Main::COLOR_SECONDARY, $config['color']['secondary']);

        return new JsonResponse($main);
    }

    /**
     * @return \Illuminate\Http\Response json response with a auja message
     */
    public function login() {

        $this->app['auth']->attempt([
            'email' => $this->app['request']->input('email'),
            'password' => $this->app['request']->input('password')
        ]);

        $message = new Message();
        $message->setAuthenticated($this->app['auth']->check());

        return new JsonResponse($message);
    }

    /**
     * @return \Illuminate\Http\Response redirects to the index after logout.
     */
    public function logout() {

        $this->app['auth']->logout();

        return $this->app['redirect']->route(
            'auja.support.index'
        );
    }

}


<?php

namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;

use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException;

class ContentTypes extends WriterPart
{
    /**
     * Write content types to XML format.
     *
     * @param Spreadsheet $spreadsheet
     * @param bool $includeCharts Flag indicating if we should include drawing details for charts
     *
     * @throws WriterException
     *
     * @return string XML Output
     */
    public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = false)
    {
        // Create XML writer
        $objWriter = null;
        if ($this->getParentWriter()->getUseDiskCaching()) {
            $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
        } else {
            $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
        }

        // XML header
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');

        // Types
        $objWriter->startElement('Types');
        $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');

        // Theme
        $this->writeOverrideContentType($objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml');

        // Styles
        $this->writeOverrideContentType($objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml');

        // Rels
        $this->writeDefaultContentType($objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml');

        // XML
        $this->writeDefaultContentType($objWriter, 'xml', 'application/xml');

        // VML
        $this->writeDefaultContentType($objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing');

        // Workbook
        if ($spreadsheet->hasMacros()) { //Macros in workbook ?
            // Yes : not standard content but "macroEnabled"
            $this->writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml');
            //... and define a new type for the VBA project
            $this->writeDefaultContentType($objWriter, 'bin', 'application/vnd.ms-office.vbaProject');
            if ($spreadsheet->hasMacrosCertificate()) {
                // signed macros ?
                // Yes : add needed information
                $this->writeOverrideContentType($objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature');
            }
        } else {
            // no macros in workbook, so standard type
            $this->writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml');
        }

        // DocProps
        $this->writeOverrideContentType($objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml');

        $this->writeOverrideContentType($objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml');

        $customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
        if (!empty($customPropertyList)) {
            $this->writeOverrideContentType($objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml');
        }

        // Worksheets
        $sheetCount = $spreadsheet->getSheetCount();
        for ($i = 0; $i < $sheetCount; ++$i) {
            $this->writeOverrideContentType($objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml');
        }

        // Shared strings
        $this->writeOverrideContentType($objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml');

        // Add worksheet relationship content types
        $chart = 1;
        for ($i = 0; $i < $sheetCount; ++$i) {
            $drawings = $spreadsheet->getSheet($i)->getDrawingCollection();
            $drawingCount = count($drawings);
            $chartCount = ($includeCharts) ? $spreadsheet->getSheet($i)->getChartCount() : 0;

            //    We need a drawing relationship for the worksheet if we have either drawings or charts
            if (($drawingCount > 0) || ($chartCount > 0)) {
                $this->writeOverrideContentType($objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml');
            }

            //    If we have charts, then we need a chart relationship for every individual chart
            if ($chartCount > 0) {
                for ($c = 0; $c < $chartCount; ++$c) {
                    $this->writeOverrideContentType($objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml');
                }
            }
        }

        // Comments
        for ($i = 0; $i < $sheetCount; ++$i) {
            if (count($spreadsheet->getSheet($i)->getComments()) > 0) {
                $this->writeOverrideContentType($objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml');
            }
        }

        // Add media content-types
        $aMediaContentTypes = [];
        $mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
        for ($i = 0; $i < $mediaCount; ++$i) {
            $extension = '';
            $mimeType = '';

            if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) {
                $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
                $mimeType = $this->getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath());
            } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) {
                $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
                $extension = explode('/', $extension);
                $extension = $extension[1];

                $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
            }

            if (!isset($aMediaContentTypes[$extension])) {
                $aMediaContentTypes[$extension] = $mimeType;

                $this->writeDefaultContentType($objWriter, $extension, $mimeType);
            }
        }
        if ($spreadsheet->hasRibbonBinObjects()) {
            // Some additional objects in the ribbon ?
            // we need to write "Extension" but not already write for media content
            $tabRibbonTypes = array_diff($spreadsheet->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
            foreach ($tabRibbonTypes as $aRibbonType) {
                $mimeType = 'image/.' . $aRibbonType; //we wrote $mimeType like customUI Editor
                $this->writeDefaultContentType($objWriter, $aRibbonType, $mimeType);
            }
        }
        $sheetCount = $spreadsheet->getSheetCount();
        for ($i = 0; $i < $sheetCount; ++$i) {
            if (count($spreadsheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
                foreach ($spreadsheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
                    if (!isset($aMediaContentTypes[strtolower($image->getExtension())])) {
                        $aMediaContentTypes[strtolower($image->getExtension())] = $this->getImageMimeType($image->getPath());

                        $this->writeDefaultContentType($objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]);
                    }
                }
            }
        }

        $objWriter->endElement();

        // Return
        return $objWriter->getData();
    }

    /**
     * Get image mime type.
     *
     * @param string $pFile Filename
     *
     * @throws WriterException
     *
     * @return string Mime Type
     */
    private function getImageMimeType($pFile)
    {
        if (File::fileExists($pFile)) {
            $image = getimagesize($pFile);

            return image_type_to_mime_type($image[2]);
        }

        throw new WriterException("File $pFile does not exist");
    }

    /**
     * Write Default content type.
     *
     * @param XMLWriter $objWriter XML Writer
     * @param string $pPartname Part name
     * @param string $pContentType Content type
     *
     * @throws WriterException
     */
    private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pContentType)
    {
        if ($pPartname != '' && $pContentType != '') {
            // Write content type
            $objWriter->startElement('Default');
            $objWriter->writeAttribute('Extension', $pPartname);
            $objWriter->writeAttribute('ContentType', $pContentType);
            $objWriter->endElement();
        } else {
            throw new WriterException('Invalid parameters passed.');
        }
    }

    /**
     * Write Override content type.
     *
     * @param XMLWriter $objWriter XML Writer
     * @param string $pPartname Part name
     * @param string $pContentType Content type
     *
     * @throws WriterException
     */
    private function writeOverrideContentType(XMLWriter $objWriter, $pPartname, $pContentType)
    {
        if ($pPartname != '' && $pContentType != '') {
            // Write content type
            $objWriter->startElement('Override');
            $objWriter->writeAttribute('PartName', $pPartname);
            $objWriter->writeAttribute('ContentType', $pContentType);
            $objWriter->endElement();
        } else {
            throw new WriterException('Invalid parameters passed.');
        }
    }
}


<?php

namespace PhpOffice\PhpSpreadsheet\Worksheet;

/**
 * <code>
 * Header/Footer Formatting Syntax taken from Office Open XML Part 4 - Markup Language Reference, page 1970:.
 *
 * There are a number of formatting codes that can be written inline with the actual header / footer text, which
 * affect the formatting in the header or footer.
 *
 * Example: This example shows the text "Center Bold Header" on the first line (center section), and the date on
 * the second line (center section).
 *         &CCenter &"-,Bold"Bold&"-,Regular"Header_x000A_&D
 *
 * General Rules:
 * There is no required order in which these codes must appear.
 *
 * The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
 * - strikethrough
 * - superscript
 * - subscript
 * Superscript and subscript cannot both be ON at same time. Whichever comes first wins and the other is ignored,
 * while the first is ON.
 * &L - code for "left section" (there are three header / footer locations, "left", "center", and "right"). When
 * two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the
 * order of appearance, and placed into the left section.
 * &P - code for "current page #"
 * &N - code for "total pages"
 * &font size - code for "text font size", where font size is a font size in points.
 * &K - code for "text font color"
 * RGB Color is specified as RRGGBB
 * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade
 * value, NN is the tint/shade value.
 * &S - code for "text strikethrough" on / off
 * &X - code for "text super script" on / off
 * &Y - code for "text subscript" on / off
 * &C - code for "center section". When two or more occurrences of this section marker exist, the contents
 * from all markers are concatenated, in the order of appearance, and placed into the center section.
 *
 * &D - code for "date"
 * &T - code for "time"
 * &G - code for "picture as background"
 * &U - code for "text single underline"
 * &E - code for "double underline"
 * &R - code for "right section". When two or more occurrences of this section marker exist, the contents
 * from all markers are concatenated, in the order of appearance, and placed into the right section.
 * &Z - code for "this workbook's file path"
 * &F - code for "this workbook's file name"
 * &A - code for "sheet tab name"
 * &+ - code for add to page #.
 * &- - code for subtract from page #.
 * &"font name,font type" - code for "text font name" and "text font type", where font name and font type
 * are strings specifying the name and type of the font, separated by a comma. When a hyphen appears in font
 * name, it means "none specified". Both of font name and font type can be localized values.
 * &"-,Bold" - code for "bold font style"
 * &B - also means "bold font style".
 * &"-,Regular" - code for "regular font style"
 * &"-,Italic" - code for "italic font style"
 * &I - also means "italic font style"
 * &"-,Bold Italic" code for "bold italic font style"
 * &O - code for "outline style"
 * &H - code for "shadow style"
 * </code>
 */
class HeaderFooter
{
    // Header/footer image location
    const IMAGE_HEADER_LEFT = 'LH';
    const IMAGE_HEADER_CENTER = 'CH';
    const IMAGE_HEADER_RIGHT = 'RH';
    const IMAGE_FOOTER_LEFT = 'LF';
    const IMAGE_FOOTER_CENTER = 'CF';
    const IMAGE_FOOTER_RIGHT = 'RF';

    /**
     * OddHeader.
     *
     * @var string
     */
    private $oddHeader = '';

    /**
     * OddFooter.
     *
     * @var string
     */
    private $oddFooter = '';

    /**
     * EvenHeader.
     *
     * @var string
     */
    private $evenHeader = '';

    /**
     * EvenFooter.
     *
     * @var string
     */
    private $evenFooter = '';

    /**
     * FirstHeader.
     *
     * @var string
     */
    private $firstHeader = '';

    /**
     * FirstFooter.
     *
     * @var string
     */
    private $firstFooter = '';

    /**
     * Different header for Odd/Even, defaults to false.
     *
     * @var bool
     */
    private $differentOddEven = false;

    /**
     * Different header for first page, defaults to false.
     *
     * @var bool
     */
    private $differentFirst = false;

    /**
     * Scale with document, defaults to true.
     *
     * @var bool
     */
    private $scaleWithDocument = true;

    /**
     * Align with margins, defaults to true.
     *
     * @var bool
     */
    private $alignWithMargins = true;

    /**
     * Header/footer images.
     *
     * @var HeaderFooterDrawing[]
     */
    private $headerFooterImages = [];

    /**
     * Create a new HeaderFooter.
     */
    public function __construct()
    {
    }

    /**
     * Get OddHeader.
     *
     * @return string
     */
    public function getOddHeader()
    {
        return $this->oddHeader;
    }

    /**
     * Set OddHeader.
     *
     * @param string $pValue
     *
     * @return HeaderFooter
     */
    public function setOddHeader($pValue)
    {
        $this->oddHeader = $pValue;

        return $this;
    }

    /**
     * Get OddFooter.
     *
     * @return string
     */
    public function getOddFooter()
    {
        return $this->oddFooter;
    }

    /**
     * Set OddFooter.
     *
     * @param string $pValue
     *
     * @return HeaderFooter
     */
    public function setOddFooter($pValue)
    {
        $this->oddFooter = $pValue;

        return $this;
    }

    /**
     * Get EvenHeader.
     *
     * @return string
     */
    public function getEvenHeader()
    {
        return $this->evenHeader;
    }

    /**
     * Set EvenHeader.
     *
     * @param string $pValue
     *
     * @return HeaderFooter
     */
    public function setEvenHeader($pValue)
    {
        $this->evenHeader = $pValue;

        return $this;
    }

    /**
     * Get EvenFooter.
     *
     * @return string
     */
    public function getEvenFooter()
    {
        return $this->evenFooter;
    }

    /**
     * Set EvenFooter.
     *
     * @param string $pValue
     *
     * @return HeaderFooter
     */
    public function setEvenFooter($pValue)
    {
        $this->evenFooter = $pValue;

        return $this;
    }

    /**
     * Get FirstHeader.
     *
     * @return string
     */
    public function getFirstHeader()
    {
        return $this->firstHeader;
    }

    /**
     * Set FirstHeader.
     *
     * @param string $pValue
     *
     * @return HeaderFooter
     */
    public function setFirstHeader($pValue)
    {
        $this->firstHeader = $pValue;

        return $this;
    }

    /**
     * Get FirstFooter.
     *
     * @return string
     */
    public function getFirstFooter()
    {
        return $this->firstFooter;
    }

    /**
     * Set FirstFooter.
     *
     * @param string $pValue
     *
     * @return HeaderFooter
     */
    public function setFirstFooter($pValue)
    {
        $this->firstFooter = $pValue;

        return $this;
    }

    /**
     * Get DifferentOddEven.
     *
     * @return bool
     */
    public function getDifferentOddEven()
    {
        return $this->differentOddEven;
    }

    /**
     * Set DifferentOddEven.
     *
     * @param bool $pValue
     *
     * @return HeaderFooter
     */
    public function setDifferentOddEven($pValue)
    {
        $this->differentOddEven = $pValue;

        return $this;
    }

    /**
     * Get DifferentFirst.
     *
     * @return bool
     */
    public function getDifferentFirst()
    {
        return $this->differentFirst;
    }

    /**
     * Set DifferentFirst.
     *
     * @param bool $pValue
     *
     * @return HeaderFooter
     */
    public function setDifferentFirst($pValue)
    {
        $this->differentFirst = $pValue;

        return $this;
    }

    /**
     * Get ScaleWithDocument.
     *
     * @return bool
     */
    public function getScaleWithDocument()
    {
        return $this->scaleWithDocument;
    }

    /**
     * Set ScaleWithDocument.
     *
     * @param bool $pValue
     *
     * @return HeaderFooter
     */
    public function setScaleWithDocument($pValue)
    {
        $this->scaleWithDocument = $pValue;

        return $this;
    }

    /**
     * Get AlignWithMargins.
     *
     * @return bool
     */
    public function getAlignWithMargins()
    {
        return $this->alignWithMargins;
    }

    /**
     * Set AlignWithMargins.
     *
     * @param bool $pValue
     *
     * @return HeaderFooter
     */
    public function setAlignWithMargins($pValue)
    {
        $this->alignWithMargins = $pValue;

        return $this;
    }

    /**
     * Add header/footer image.
     *
     * @param HeaderFooterDrawing $image
     * @param string $location
     *
     * @return HeaderFooter
     */
    public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEADER_LEFT)
    {
        $this->headerFooterImages[$location] = $image;

        return $this;
    }

    /**
     * Remove header/footer image.
     *
     * @param string $location
     *
     * @return HeaderFooter
     */
    public function removeImage($location = self::IMAGE_HEADER_LEFT)
    {
        if (isset($this->headerFooterImages[$location])) {
            unset($this->headerFooterImages[$location]);
        }

        return $this;
    }

    /**
     * Set header/footer images.
     *
     * @param HeaderFooterDrawing[] $images
     *
     * @return HeaderFooter
     */
    public function setImages(array $images)
    {
        $this->headerFooterImages = $images;

        return $this;
    }

    /**
     * Get header/footer images.
     *
     * @return HeaderFooterDrawing[]
     */
    public function getImages()
    {
        // Sort array
        $images = [];
        if (isset($this->headerFooterImages[self::IMAGE_HEADER_LEFT])) {
            $images[self::IMAGE_HEADER_LEFT] = $this->headerFooterImages[self::IMAGE_HEADER_LEFT];
        }
        if (isset($this->headerFooterImages[self::IMAGE_HEADER_CENTER])) {
            $images[self::IMAGE_HEADER_CENTER] = $this->headerFooterImages[self::IMAGE_HEADER_CENTER];
        }
        if (isset($this->headerFooterImages[self::IMAGE_HEADER_RIGHT])) {
            $images[self::IMAGE_HEADER_RIGHT] = $this->headerFooterImages[self::IMAGE_HEADER_RIGHT];
        }
        if (isset($this->headerFooterImages[self::IMAGE_FOOTER_LEFT])) {
            $images[self::IMAGE_FOOTER_LEFT] = $this->headerFooterImages[self::IMAGE_FOOTER_LEFT];
        }
        if (isset($this->headerFooterImages[self::IMAGE_FOOTER_CENTER])) {
            $images[self::IMAGE_FOOTER_CENTER] = $this->headerFooterImages[self::IMAGE_FOOTER_CENTER];
        }
        if (isset($this->headerFooterImages[self::IMAGE_FOOTER_RIGHT])) {
            $images[self::IMAGE_FOOTER_RIGHT] = $this->headerFooterImages[self::IMAGE_FOOTER_RIGHT];
        }
        $this->headerFooterImages = $images;

        return $this->headerFooterImages;
    }

    /**
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
     */
    public function __clone()
    {
        $vars = get_object_vars($this);
        foreach ($vars as $key => $value) {
            if (is_object($value)) {
                $this->$key = clone $value;
            } else {
                $this->$key = $value;
            }
        }
    }
}


<?php

namespace PhpOffice\PhpSpreadsheet\Worksheet;

class Column
{
    /**
     * \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet.
     *
     * @var Worksheet
     */
    private $parent;

    /**
     * Column index.
     *
     * @var string
     */
    private $columnIndex;

    /**
     * Create a new column.
     *
     * @param Worksheet $parent
     * @param string $columnIndex
     */
    public function __construct(Worksheet $parent = null, $columnIndex = 'A')
    {
        // Set parent and column index
        $this->parent = $parent;
        $this->columnIndex = $columnIndex;
    }

    /**
     * Destructor.
     */
    public function __destruct()
    {
        unset($this->parent);
    }

    /**
     * Get column index.
     *
     * @return string
     */
    public function getColumnIndex()
    {
        return $this->columnIndex;
    }

    /**
     * Get cell iterator.
     *
     * @param int $startRow The row number at which to start iterating
     * @param int $endRow Optionally, the row number at which to stop iterating
     *
     * @return ColumnCellIterator
     */
    public function getCellIterator($startRow = 1, $endRow = null)
    {
        return new ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow);
    }
}


<?php

namespace RodrigoPedra\ClearSaleID\Entity\Request;

use RodrigoPedra\ClearSaleID\Entity\XmlEntityInterface;
use RodrigoPedra\ClearSaleID\Exception\RequiredFieldException;
use XMLWriter;

class FingerPrint implements XmlEntityInterface
{
    /** @var  string */
    private $sessionId;

    /**
     * FingerPrint constructor.
     *
     * @param  string $sessionId
     */
    public function __construct( $sessionId )
    {
        $this->sessionId = $sessionId;
    }

    /**
     * @return string
     */
    public function getSessionId()
    {
        return $this->sessionId;
    }

    /**
     * @param  string $sessionId
     *
     * @return $this
     */
    public function setSessionId( $sessionId )
    {
        $this->sessionId = $sessionId;

        return $this;
    }

    /**
     * @param  \XMLWriter $XMLWriter
     *
     * @throws \RodrigoPedra\ClearSaleID\Exception\RequiredFieldException
     */
    public function toXML( XMLWriter $XMLWriter )
    {
        if ($this->sessionId) {
            $XMLWriter->writeElement( 'SessionID', $this->sessionId );
        } else {
            throw new RequiredFieldException( 'Field SessionID of the FingerPrint object is required' );
        }
    }
}