<commit_before><?php

class Blob_IndexController extends Zend_Controller_Action
{

    protected $_session = null;

    public function init()
    {
        $this->_session = new Zend_Session_Namespace(Application_Service_AzureBlob::WASA_SERVICE);
    }

    public function indexAction()
    {
        return $this->_helper->redirector('container', 'index', 'blob');
    }

    public function browseAction()
    {
        $container = $this->getRequest()->getParam('container', null);
        $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
        $containers = $azureBlob->listContainers();
        if (null === $container && !empty ($containers)) {
            $container = $containers[0]->getName();
        }
        $this->_session->lastContainer = $container;
        $blobs = $azureBlob->listBlobs($container);
        
        $this->view->assign(array (
            'containers' => $containers,
            'blobs' => $blobs,
            'lastContainer' => $this->_session->lastContainer,
        ));
    }

    public function addContainerAction()
    {
        // action body
    }

    public function removeContainerAction()
    {
        $container = $this->getRequest()->getParam('container', null);
        if (null !== $container) {
            $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
            $azureBlob->removeContainer($container);
        }
        return $this->_helper->redirector('container', 'index', 'blob');
    }

    public function addBlobAction()
    {
        $container = $this->getRequest()->getParam('container', null);
        $this->view->container = $container;
    }

    public function removeBlobAction()
    {
        $blobName = $this->getRequest()->getParam('file', null);
        if (null !== $blobName) {
            $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
            $azureBlob->removeBlob($this->_session->lastContainer, $blobName);
        }
        return $this->_helper->redirector('browse', 'index', 'blob', array ('container' => $this->_session->lastContainer));
    }

    public function containerAction()
    {
        $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
        $containers = $azureBlob->listContainers();
        $this->view->assign(array (
            'containers' => $containers,
        ));
    }

    public function uploadBlobAction()
    {
        var_dump($_FILES);
        if (isset ($_FILES['file']['tmp_name'])) {
            $basename = substr($_FILES['file']['tmp_name'], 0, strrpos($_FILES['file']['tmp_name'], '/'));
            $it = new DirectoryIterator($basename);
            $cnt = 0;
            while($it->valid()) {
                if ($it->isDot()) continue;
                $cnt++;
                $it->next();
            }
        }
        var_dump($it);

        die;
        $results = array ();
        if (!empty ($_FILES)){
            foreach ($_FILES['file']['error'] as $key => $error) {
                $file = array (
                    'name' => $_FILES['file']['name'][$key],
                    'type' => $_FILES['file']['type'][$key],
                    'size' => $_FILES['file']['size'][$key],<commit_msg>Listing files in temp dir<commit_after><?php

class Blob_IndexController extends Zend_Controller_Action
{

    protected $_session = null;

    public function init()
    {
        $this->_session = new Zend_Session_Namespace(Application_Service_AzureBlob::WASA_SERVICE);
    }

    public function indexAction()
    {
        return $this->_helper->redirector('container', 'index', 'blob');
    }

    public function browseAction()
    {
        $container = $this->getRequest()->getParam('container', null);
        $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
        $containers = $azureBlob->listContainers();
        if (null === $container && !empty ($containers)) {
            $container = $containers[0]->getName();
        }
        $this->_session->lastContainer = $container;
        $blobs = $azureBlob->listBlobs($container);
        
        $this->view->assign(array (
            'containers' => $containers,
            'blobs' => $blobs,
            'lastContainer' => $this->_session->lastContainer,
        ));
    }

    public function addContainerAction()
    {
        // action body
    }

    public function removeContainerAction()
    {
        $container = $this->getRequest()->getParam('container', null);
        if (null !== $container) {
            $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
            $azureBlob->removeContainer($container);
        }
        return $this->_helper->redirector('container', 'index', 'blob');
    }

    public function addBlobAction()
    {
        $container = $this->getRequest()->getParam('container', null);
        $this->view->container = $container;
    }

    public function removeBlobAction()
    {
        $blobName = $this->getRequest()->getParam('file', null);
        if (null !== $blobName) {
            $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
            $azureBlob->removeBlob($this->_session->lastContainer, $blobName);
        }
        return $this->_helper->redirector('browse', 'index', 'blob', array ('container' => $this->_session->lastContainer));
    }

    public function containerAction()
    {
        $azureBlob = new Application_Service_AzureBlob($this->_session->creds['account_name'], $this->_session->creds['account_key']);
        $containers = $azureBlob->listContainers();
        $this->view->assign(array (
            'containers' => $containers,
        ));
    }

    public function uploadBlobAction()
    {
        var_dump($_FILES);
        if (isset ($_FILES['file']['tmp_name'][0])) {
            $basename = substr($_FILES['file']['tmp_name'][0], 0, strrpos($_FILES['file']['tmp_name'][0], '/'));
            $it = new DirectoryIterator($basename);
            while ($it->valid()) {
                var_dump($it->getPathname());
                $it->next();
            }
        }

        die;
        $results = array ();
        if (!empty ($_FILES)){
            foreach ($_FILES['file']['error'] as $key => $error) {
                $file = array (
                    'name' => $_FILES['file']['name'][$key],
                    'type' => $_FILES['file']['type'][$key],
                    'size' => $_FILES['file']['size'][$key],
{'fraction_non_alphanumeric': 0.17183180561617925, 'fraction_numerical': 0.0011639749745380474, 'mean_word_length': 2.5672029060716137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '824164', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1853, 'n_words': 314}