Phalcon Framework 2.0.9

Exception: fasdf

/home/ubuntu/partsit-site/app/models/SubCategories.php (47)
#0Models\SubCategories::findFromURL(networking, telecommunications, gps-products)
/home/ubuntu/partsit-site/app/controllers/CategoryController.php (631)
<?php
 
namespace Controllers;
 
class CategoryController extends \Controllers\ControllerBase
{
  public function indexAction()
  {
    return $this->response->redirect(
      'categories'
    );
  }
  
  
  
  public function sectionAction()
  {
    $selectedSectionURL = $this->dispatcher->getParam('sectionURL', 'urlSlug');
    
    $pageNumber = $this->request->getQuery('page') ?: 1;
    
    $query = $this->request->getQuery('q', 'trim');
    
    $selectedManufacturerURL = $this->request->getQuery('manufacturer', 'urlSlug');
    $selectedModelNumberID   = $this->request->getQuery('modelNumber',  'int');
    
    
    
    $selectedTechSpecs = $this->request->getQuery('techSpecs');
    
    
    
    $showOnlyStock = !!$this->request->getQuery('onlyStock');
    
    
    
    
    $itemsPerPage = $this->request->getQuery('itemsPerPage', 'int', 10);
    
    
    
    // Force a hard maximum of 100 for the items per page.
    $itemsPerPage = min($itemsPerPage, 100);
    
    
    
    
    
    
    $selectedSection = \Models\Sections::findFromURL(
      $selectedSectionURL
    );
    
    if (!$selectedSection) {
      return $this->error404();
    }
    
    
    
    
    
    $selectedManufacturer = ($selectedManufacturerURL)
        ? \Models\Manufacturers::findFromURL($selectedManufacturerURL)
        : false;
    
    $selectedModelNumber = ($selectedModelNumberID)
        ? \Models\ModelNumbers::findFirstByModelNumberID($selectedModelNumberID)
        : false;
    
    
    
    
    
    $searchParameters = array(
      $query,
      
      'onlyStock'     => $showOnlyStock,
      
      'section'       => $selectedSection,
      
      'manufacturer'  => $selectedManufacturer,
      'modelNumber'   => $selectedModelNumber,
      
      'partTechSpecs' => array(),
      
      'sort'          => array(
        'manufacturer' => 'ASC',
        'partNumber'   => 'ASC'
      )
    );
 
        $nonMan = array(
            $query,
 
            'onlyStock'     => $showOnlyStock,
 
            'section'       => $selectedSection,
 
            'modelNumber'   => $selectedModelNumber,
 
            'partTechSpecs' => array(),
 
            'sort'          => array(
                'manufacturer' => 'ASC',
                'partNumber'   => 'ASC'
            )
        );
    
    
    
    if ($selectedTechSpecs) {
      foreach ($selectedTechSpecs as $selectedTechSpecName => $selectedTechSpecValue) {
        if (!$selectedTechSpecName) {
          continue;
        }
        
        $selectedTechSpecName = preg_replace('/[^a-z0-9]+/i', '', $selectedTechSpecName);
        
        $searchParameters['partTechSpecs'][$selectedTechSpecName] = $selectedTechSpecValue;
      }
    }
    
    
    
    
    
    $results = \Models\Parts::search(
      $searchParameters,
      $pageNumber,
      $itemsPerPage
    );
    
    
    
    $parts        = $results['parts'];
    $totalResults = $results['totalResults'];
    
    
    
    
    
    $url = '/category/' . $selectedSectionURL . '/';
    
    
    $url .= '?' . http_build_query(
      array(
        'q'            => $query,
        
        'onlyStock'    => $showOnlyStock,
        'manufacturer' => $selectedManufacturerURL,
        'modelNumber'  => $selectedModelNumberID,
        
        'itemsPerPage' => $itemsPerPage,
        
        'page'         => ''
      ),
      null,
      '&amp;'
    );
    
    
    $sections = \Models\Sections::find(
      array(
        'order' => 'section ASC'
      )
    );
    
    $categories = $selectedSection->getCategories(
      array(
        'order' => 'category ASC'
      )
    );
    
    
    $filterManufacturers = \Models\Parts::searchDistinct('manufacturerID', $nonMan, 1000);
    
    $filterSystemManufacturers = \Models\Parts::searchDistinct('systemManufacturerID',  $searchParameters, 1000);
    $filterModelFamilies       = \Models\Parts::searchDistinct('modelFamilyID',         $searchParameters, 1000);
    $filterModelNumbers        = \Models\Parts::searchDistinct('modelNumberID',         $searchParameters, 1000);
    
    
    
    $manufacturers = \Models\Manufacturers::find(
      array(
        'order' => 'manufacturer ASC'
      )
    );
    
    
    
    $techSpecs = \Models\Parts::searchTechSpecs($searchParameters);
    
    
    
    $this->view->sections   = $sections;
    $this->view->categories = $categories;
    $this->view->techSpecs  = $techSpecs;
    
    
    
    
    $this->view->filterManufacturers = $filterManufacturers;
    
    
    $this->view->filterSystemManufacturers = $filterSystemManufacturers;
    $this->view->filterModelFamilies       = $filterModelFamilies;
    $this->view->filterModelNumbers        = $filterModelNumbers;
    
    
    
    $this->view->manufacturers = $manufacturers;
    
    
    $this->view->parts = $parts;
    
    $this->view->selectedSection      = $selectedSection;
    $this->view->selectedManufacturer = $selectedManufacturer;
    $this->view->selectedTechSpecs    = $selectedTechSpecs;
    $this->view->selectedModelNumber  = $selectedModelNumber;
    
    $this->view->itemsPerPage = $itemsPerPage;
    
    $this->view->query = $query;
    
    $this->view->showOnlyStock = $showOnlyStock;
    
    $this->view->totalResults = $totalResults;
    
    
    
    $this->view->pagination = array(
      'pageNumber'   => $pageNumber,
      'itemsPerPage' => $itemsPerPage,
      'totalItems'   => $totalResults,
      'url'          => $url,
      'what'         => 'product'
    );
    
    
    
    $this->tag->prependTitle(
      $selectedSection->getSection() . ' parts | '
    );
    //Show Special offers on the side of search reults.
 
    
    $d = \Models\Metadata::findFirst('category = "promotional" and name = "distributors"');
    $distis = json_decode($d->getValue(), true);
 
    //get selected SECTION
    $getSec = $selectedSection->getSection();
 
    $cats = array();
    foreach($categories as $cat) {
      $cats[] = $cat->getCategoryURL();
    }
 
        $manus = array();
 
         $fs = array(
          'distributor_urls' => $distis,
      'category_urls' => $cats,
           'manufacturer_urls' => $manus
         );
    
        //get 4 random special offers per page, including a mail shot entry if we need to.
        $msi = mt_rand(0, 4);
        $template = new \Template();
        $template->setTemplateDir('offer-views');
 
        $offers = \Models\PromoParts::getSitePromotions($fs, 2, 1, false);
 
        //render the html for the selected offers.
        //format the params.
        $params = array();
        if(count($offers > 0)) {
            for($i = 0; $i < count($offers); $i++) {
                if($i == $msi) {
                    //enter this first at this index.
                    $params[] = array(
                        'type' => 'mailshot',
                        'object' => null
                    );
                }
                $params[] = array('type' => 'promo', 'object' => $offers[$i]);
            }
        }
 
        $html = $template->renderTemplate('offers', 'home', array('objects' => $params));
 
        $this->view->initialOffers = $html;
  }
  
  
  public function categoryAction()
  {
    $selectedSectionURL  = $this->dispatcher->getParam('sectionURL',  'urlSlug');
    $selectedCategoryURL = $this->dispatcher->getParam('categoryURL', 'urlSlug');
    
    $pageNumber = $this->request->getQuery('page') ?: 1;
    
    $query = $this->request->getQuery('q', 'trim');
    
    $selectedManufacturerURL = $this->request->getQuery('manufacturer', 'urlSlug');
    $selectedModelNumberID   = $this->request->getQuery('modelNumber',  'int');
    
    
    
    $selectedTechSpecs = $this->request->getQuery('techSpecs');
    
    
    
    $showOnlyStock = !!$this->request->getQuery('onlyStock');
    
    
    
    
    $itemsPerPage = $this->request->getQuery('itemsPerPage', 'int', 10);
    
    
    
    // Force a hard maximum of 100 for the items per page.
    $itemsPerPage = min($itemsPerPage, 100);
    
    
    
    
    
    
    $selectedCategory = \Models\Categories::findFromURL(
      $selectedSectionURL,
      $selectedCategoryURL
    );
    
    if (!$selectedCategory) {
      return $this->error404();
    }
    
    $selectedSection = $selectedCategory->getSections();
    
    
    
    
    
    $selectedManufacturer = ($selectedManufacturerURL)
        ? \Models\Manufacturers::findFromURL($selectedManufacturerURL)
        : false;
    
    $selectedModelNumber = ($selectedModelNumberID)
        ? \Models\ModelNumbers::findFirstByModelNumberID($selectedModelNumberID)
        : false;
    
    
    
    
    
    $searchParameters = array(
      $query,
 
      'onlyStock'     => $showOnlyStock,
 
      'category'      => $selectedCategory,
 
      'manufacturer'  => $selectedManufacturer,
      'modelNumber'   => $selectedModelNumber,
 
      'partTechSpecs' => array(),
 
      'sort'          => array(
        'manufacturer' => 'ASC',
        'partNumber'   => 'ASC'
      )
    );
 
        $nonMan = array(
            $query,
 
            'onlyStock'     => $showOnlyStock,
 
            'category'      => $selectedCategory,
 
            'modelNumber'   => $selectedModelNumber,
 
            'partTechSpecs' => array(),
 
            'sort'          => array(
                'manufacturer' => 'ASC',
                'partNumber'   => 'ASC'
            )
        );
    
    
    
    if ($selectedTechSpecs) {
      foreach ($selectedTechSpecs as $selectedTechSpecName => $selectedTechSpecValue) {
        if (!$selectedTechSpecName) {
          continue;
        }
        
        $selectedTechSpecName = preg_replace('/[^a-z0-9]+/i', '', $selectedTechSpecName);
        
        $searchParameters['partTechSpecs'][$selectedTechSpecName] = $selectedTechSpecValue;
      }
    }
    
    
    
    
    
    $results = \Models\Parts::search(
      $searchParameters,
      $pageNumber,
      $itemsPerPage
    );
    
    
    
    $parts        = $results['parts'];
    $totalResults = $results['totalResults'];
    
    
    
    
    
    $url = '/category/' . $selectedSectionURL . '/' . $selectedCategoryURL . '/';
    
    
    $url .= '?' . http_build_query(
      array(
        'q'            => $query,
        
        'onlyStock'    => $showOnlyStock,
        'manufacturer' => $selectedManufacturerURL,
        'modelNumber'  => $selectedModelNumberID,
        
        'itemsPerPage' => $itemsPerPage,
        
        'page'         => ''
      ),
      null,
      '&amp;'
    );
    
    
    $sections = \Models\Sections::find(
      array(
        'order' => 'section ASC'
      )
    );
    
    $categories = $selectedSection->getCategories(
      array(
        'order' => 'category ASC'
      )
    );
    
    $subCategories = $selectedCategory->getSubCategories(
      array(
        'order' => 'subCategory ASC'
      )
    );
    
    
    
    //TODO
    $filterManufacturers = \Models\Parts::searchDistinct('manufacturerID', $nonMan, 1000);
    
    $filterSystemManufacturers = \Models\Parts::searchDistinct('systemManufacturerID',  $searchParameters, 1000);
    $filterModelFamilies       = \Models\Parts::searchDistinct('modelFamilyID',         $searchParameters, 1000);
    $filterModelNumbers        = \Models\Parts::searchDistinct('modelNumberID',         $searchParameters, 1000);
    
    
    
    $manufacturers = \Models\Manufacturers::find(
      array(
        'order' => 'manufacturer ASC'
      )
    );
    
    
    
    $techSpecs = \Models\Parts::searchTechSpecs($searchParameters);
    
    
    
    $this->view->sections      = $sections;
    $this->view->categories    = $categories;
    $this->view->subCategories = $subCategories;
    $this->view->techSpecs     = $techSpecs;
    
    
    
    
    $this->view->filterManufacturers = $filterManufacturers;
    
    
    $this->view->filterSystemManufacturers = $filterSystemManufacturers;
    $this->view->filterModelFamilies       = $filterModelFamilies;
    $this->view->filterModelNumbers        = $filterModelNumbers;
    
    
    
    $this->view->manufacturers = $manufacturers;
    
    
    $this->view->parts = $parts;
    
    $this->view->selectedSection      = $selectedSection;
    $this->view->selectedCategory     = $selectedCategory;
    $this->view->selectedManufacturer = $selectedManufacturer;
    $this->view->selectedTechSpecs    = $selectedTechSpecs;
    $this->view->selectedModelNumber  = $selectedModelNumber;
    
    $this->view->itemsPerPage = $itemsPerPage;
    
    $this->view->query           = $query;
    $this->view->manufacturerURL = @$manufacturerURL;
    
    $this->view->showOnlyStock = $showOnlyStock;
    
    $this->view->totalResults = $totalResults;
    
    
    
    $this->view->pagination = array(
      'pageNumber'   => $pageNumber,
      'itemsPerPage' => $itemsPerPage,
      'totalItems'   => $totalResults,
      'url'          => $url,
      'what'         => 'product'
    );
    
    
    
    $this->tag->prependTitle(
      $selectedCategory->getCategory() . ' parts | '
    );
 
 
 
    //Show Special offers on the side of search reults.
 
    $d = \Models\Metadata::findFirst('category = "promotional" and name = "distributors"');
    $distis = json_decode($d->getValue(), true);
    //get selected category
    $getCat = $selectedCategory->getCategoryURL();
        $cats = /*again get from database, controlled by dashboard. */array($getCat);
        $manus = array();
 
         $fs = array(
          'distributor_urls' => $distis,
      'category_urls' => $cats,
          'manufacturer_urls' => $manus
        );
 
 
        //get 4 random special offers per page, including a mail shot entry if we need to.
        $msi = mt_rand(0, 4);
        $template = new \Template();
        $template->setTemplateDir('offer-views');
 
        $offers = \Models\PromoParts::getSitePromotions($fs, 2, 1, false);
 
        //render the html for the selected offers.
        //format the params.
        $params = array();
        if(count($offers > 0)) {
            for($i = 0; $i < count($offers); $i++) {
                if($i == $msi) {
                    //enter this first at this index.
                    $params[] = array(
                        'type' => 'mailshot',
                        'object' => null
                    );
                }
                $params[] = array('type' => 'promo', 'object' => $offers[$i]);
            }
        }
 
        $html = $template->renderTemplate('offers', 'home', array('objects' => $params));
 
        $this->view->initialOffers = $html;
 
  }
  
  
  
  public function subCategoryAction()
  {
    $selectedSectionURL     = $this->dispatcher->getParam('sectionURL',     'urlSlug');
    $selectedCategoryURL    = $this->dispatcher->getParam('categoryURL',    'urlSlug');
    $selectedSubCategoryURL = $this->dispatcher->getParam('subCategoryURL', 'urlSlug');
    
    $pageNumber = $this->request->getQuery('page') ?: 1;
    
    $query = $this->request->getQuery('q', 'trim');
    
    $selectedManufacturerURL = $this->request->getQuery('manufacturer', 'urlSlug');
    $selectedModelNumberID   = $this->request->getQuery('modelNumber',  'int');
    
    
    
    $selectedTechSpecs = $this->request->getQuery('techSpecs');
    
    
    
    $showOnlyStock = !!$this->request->getQuery('onlyStock');
    
    
    
    
    
    $itemsPerPage = $this->request->getQuery('itemsPerPage', 'int', 10);
    
    
    
    // Force a hard maximum of 100 for the items per page.
    $itemsPerPage = min($itemsPerPage, 100);
    
    
    
    
    
    
    
    
    $selectedSubCategory = \Models\SubCategories::findFromURL(
      $selectedSectionURL,
      $selectedCategoryURL,
      $selectedSubCategoryURL
    );
 
 
    
    if (!$selectedSubCategory) {
      return $this->error404();
    }
    
    $selectedCategory = $selectedSubCategory->getCategories();
    $selectedSection  = $selectedCategory->getSections();
    
    
    
    
    
    $selectedManufacturer = ($selectedManufacturerURL)
        ? \Models\Manufacturers::findFromURL($selectedManufacturerURL)
        : false;
    
    $selectedModelNumber = ($selectedModelNumberID)
        ? \Models\ModelNumbers::findFirstByModelNumberID($selectedModelNumberID)
        : false;
    
    
    
    
    
    $searchParameters = array(
      $query,
      
      'onlyStock'     => $showOnlyStock,
      
      'section'       => $selectedSection,
      'category'      => $selectedCategory,
      'subCategory'   => $selectedSubCategory,
      
      'manufacturer'  => $selectedManufacturer,
      'modelNumber'   => $selectedModelNumber,
      
      'partTechSpecs' => array()
    );
 
        $nonMan = array(
            $query,
 
            'onlyStock'     => $showOnlyStock,
 
            'section'       => $selectedSection,
            'category'      => $selectedCategory,
            'subCategory'   => $selectedSubCategory,
 
            'modelNumber'   => $selectedModelNumber,
 
            'partTechSpecs' => array()
        );
    
    
    
    if ($selectedTechSpecs) {
      foreach ($selectedTechSpecs as $selectedTechSpecName => $selectedTechSpecValue) {
        if (!$selectedTechSpecName) {
          continue;
        }
        
        $selectedTechSpecName = preg_replace('/[^a-z0-9]+/i', '', $selectedTechSpecName);
        
        $searchParameters['partTechSpecs'][$selectedTechSpecName] = $selectedTechSpecValue;
      }
    }
    
    
    
    
    
    $results = \Models\Parts::search(
      $searchParameters,
      $pageNumber,
      $itemsPerPage
    );
    
    
    
    $parts        = $results['parts'];
    $totalResults = $results['totalResults'];
    
    
    
    
    
    $url = '/category/' . $selectedSectionURL . '/' . $selectedCategoryURL . '/' . $selectedSubCategoryURL . '/';
    
    
    $url .= '?' . http_build_query(
      array(
        'q'            => $query,
        
        'onlyStock'    => $showOnlyStock,
        'manufacturer' => $selectedManufacturerURL,
        'modelNumber'  => $selectedModelNumberID,
        
        'itemsPerPage' => $itemsPerPage,
        
        'page'         => ''
      ),
      null,
      '&amp;'
    );
    
    
    $sections = \Models\Sections::find(
      array(
        'order' => 'section ASC'
      )
    );
    
    $categories = $selectedSection->getCategories(
      array(
        'order' => 'category ASC'
      )
    );
    
    $subCategories = $selectedCategory->getSubCategories(
      array(
        'order' => 'subCategory ASC'
      )
    );
    
    
    
    //TODO
    $filterManufacturers = \Models\Parts::searchDistinct('manufacturerID', $nonMan, 1000);
    
    $filterSystemManufacturers = \Models\Parts::searchDistinct('systemManufacturerID',  $searchParameters, 1000);
    $filterModelFamilies       = \Models\Parts::searchDistinct('modelFamilyID',         $searchParameters, 1000);
    $filterModelNumbers        = \Models\Parts::searchDistinct('modelNumberID',         $searchParameters, 1000);
    
    
    
    $manufacturers = \Models\Manufacturers::find(
      array(
        'order' => 'manufacturer ASC'
      )
    );
    
    
    
    $techSpecs = \Models\Parts::searchTechSpecs($searchParameters);
    
    
    
    $this->view->sections      = $sections;
    $this->view->categories    = $categories;
    $this->view->subCategories = $subCategories;
    $this->view->techSpecs     = $techSpecs;
    
    
    
    
    $this->view->filterManufacturers = $filterManufacturers;
    
    
    $this->view->filterSystemManufacturers = $filterSystemManufacturers;
    $this->view->filterModelFamilies       = $filterModelFamilies;
    $this->view->filterModelNumbers        = $filterModelNumbers;
    
    
    
    $this->view->manufacturers = $manufacturers;
    
    
    $this->view->parts = $parts;
    
    $this->view->selectedSection      = $selectedSection;
    $this->view->selectedCategory     = $selectedCategory;
    $this->view->selectedSubCategory  = $selectedSubCategory;
    $this->view->selectedManufacturer = $selectedManufacturer;
    $this->view->selectedTechSpecs    = $selectedTechSpecs;
    $this->view->selectedModelNumber  = $selectedModelNumber;
    
    $this->view->itemsPerPage = $itemsPerPage;
    
    $this->view->query           = $query;
    $this->view->manufacturerURL = $manufacturerURL;
    
    $this->view->showOnlyStock = $showOnlyStock;
    
    $this->view->totalResults = $totalResults;
    
    
    
    $this->view->pagination = array(
      'pageNumber'   => $pageNumber,
      'itemsPerPage' => $itemsPerPage,
      'totalItems'   => $totalResults,
      'url'          => $url,
      'what'         => 'product'
    );
    
    
    
    $this->tag->prependTitle(
      $selectedSubCategory->getSubCategory() . ' parts | '
    );
  
    //Show Special offers on the side of search reults.
    $d = \Models\Metadata::findFirst('category = "promotional" and name = "distributors"');
    $distis = json_decode($d->getValue(), true);
    //get selected category
    $getCat = $selectedCategory->getCategoryURL();
        $cats = /*again get from database, controlled by dashboard. */array($getCat);
        $manus = array();
 
         $fs = array(
          'distributor_urls' => $distis,
      'category_urls' => $cats,
          'manufacturer_urls' => $manus
        );
 
        //get 4 random special offers per page, including a mail shot entry if we need to.
        $msi = mt_rand(0, 4);
        $template = new \Template();
        $template->setTemplateDir('offer-views');
 
        $offers = \Models\PromoParts::getSitePromotions($fs, 2, 1, false);
 
        //render the html for the selected offers.
        //format the params.
        $params = array();
        if(count($offers > 0)) {
            for($i = 0; $i < count($offers); $i++) {
                if($i == $msi) {
                    //enter this first at this index.
                    $params[] = array(
                        'type' => 'mailshot',
                        'object' => null
                    );
                }
                $params[] = array('type' => 'promo', 'object' => $offers[$i]);
            }
        }
 
        $html = $template->renderTemplate('offers', 'home', array('objects' => $params));
 
        $this->view->initialOffers = $html;
 
  }
}
#1Controllers\CategoryController->subCategoryAction(networking, telecommunications, gps-products)
#2Phalcon\Dispatcher->dispatch()
#3Phalcon\Mvc\Application->handle()
/home/ubuntu/partsit-site/app/web.php (424)
<?php
 
define('BOOTSTRAP', 'WEB');
 
if (isset($_SERVER['HTTP_X_VARNISH']) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
 
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'http') {
  header("Location: https://www.partsit.com{$_SERVER['REQUEST_URI']}");
}
 
// if(geoip_country_code_by_name($_SERVER['REMOTE_ADDR']) == 'CN') {
//   header("HTTP/1.0 404 Not Found");
//   return;
// }
 
require 'startup.php';
 
if (ENVIRONMENT == 'development') {
  $debug = new \Phalcon\Debug();
  $debug->listen();
}
 
$di->set('markdown', function($view, $di){
  $engine = new \Engine\Markdown($view, $di);
  return $engine;
});
 
 
// Setting up the view component.
$di->set(
  'view',
  function () use ($config, $di) {
    $view = new \Phalcon\Mvc\View();
    
    $view->setViewsDir($config->application->viewsDir);
    
    // Set the volt templating engine.
    $view->registerEngines(
      array(
        '.volt' => 'volt',
        '.md'   => 'markdown'
      )
    );
    
    return $view;
  }
);
 
$di->set(
  'console',
  function() {
    $console = new \Console();
    return $console;
  },true
);
 
$di->set(
  'cookies',
  function () {
    $cookies = new \Phalcon\Http\Response\Cookies();
    
    $cookies->useEncryption(false);
    
    return $cookies;
  }
);
 
$di->set(
  'viewCache',
  function () use ($config) {
    $frontCache = new \Phalcon\Cache\Frontend\Output(
      array(
        'lifetime' => $config->cache->viewCache
      )
    );
 
    $cache = new \Phalcon\Cache\Backend\APC(
      $frontCache,
      array(
        'prefix' => 'viewCache:'
      )
    );
    
    return $cache;
  }
);
 
$di->set(
  'flash',
  function () {
    $flash = new \Phalcon\Flash\Direct(
      array(
        'error'   => 'alert alert-danger',
        'success' => 'alert alert-success',
        'notice'  => 'alert alert-info',
        'warning' => 'alert alert-warning'
      )
    );
    
    return $flash;
  }
);
 
// Register the flash service with Twitter Bootstrap classes.
$di->set(
  'flashSession',
  function () {
    $flash = new \Phalcon\Flash\Session(
      array(
        'error'   => 'alert alert-danger',
        'success' => 'alert alert-success',
        'notice'  => 'alert alert-info',
        'warning' => 'alert alert-warning'
      )
    );
    
    return $flash;
  }
);
 
// Set custom dispatcher to catch events in the dispatch loop.
$di->set(
  'dispatcher',
  function () use ($di) {
    $dispatcher = new \Phalcon\Mvc\Dispatcher();
    
    $dispatcher->setDefaultNamespace('\Controllers');
    
    // Obtain the standard eventsManager from the DI.
    $eventsManager = $di->getShared('eventsManager');
    
    // Attach a listener for type "dispatch".
    $eventsManager->attach(
      'dispatch:beforeDispatchLoop',
      function ($event, $dispatcher) {
        if ($dispatcher->getActionName()) {
          $actionName = lcfirst(\Phalcon\Text::camelize($dispatcher->getActionName()));
          
          $dispatcher->setActionName($actionName);
        }
      }
    );
    
    $eventsManager->attach(
      'dispatch:beforeException',
      function ($event, $dispatcher, $exception) {
        switch ($exception->getCode()) {
          case \Phalcon\Mvc\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
          case \Phalcon\Mvc\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
            $dispatcher->forward(
              array(
                'controller' => 'error',
                'action'     => 'route404'
              )
            );
            
            return false;
        }
      }
    );
    
    $dispatcher->setEventsManager($eventsManager);
    
    return $dispatcher;
  },
  true
);
 
$di->set(
  'url',
  function () {
    $url = new \Phalcon\Mvc\Url();
    
    // if (ENVIRONMENT == 'production') {
    //   $url->setBaseUri('http://www.partsit.com/');
    // }
    
    return $url;
  }
);
 
/*
 * Start the session the first time when some component request the session
 * service.
 */
$di->setShared(
  'session',
  function () {
    $session = new \Phalcon\Session\Adapter\Files();
    
    $session->start();
    
    return $session;
  }
);
 
$di->set(
  'logger',
  function () use ($logger) {
    return $logger;
  }
);
 
// Set up custom routes in the application.
$di->set(
  'router',
  function () {
    $router = new \Phalcon\Mvc\Router(false);
    
    $router->removeExtraSlashes(true);
    
    $router->add(
      '/:controller',
      array(
        'controller' => 1
      )
    );
    
    $router->add(
      '/:controller/([a-zA-Z0-9\-]+)/:params',
      array(
        'controller' => 1,
        'action'     => 2,
        'params'     => 3
      )
    )->convert(
      'action',
      function ($action) {
        return \Phalcon\Text::camelize($action);
      }
    );
 
    $router->add('/applegate.csv', 'applegate::index');
    //$router->add('/sitemap.xml',    'sitemap::file');
 
    //add all of the old links, and redirect to new equivilent
    $router->add('/support/sitemap', 'sitemap::index');
    $router->add('/support/partsit-com-rma-returns-request-terms-conditions', 'support::returnsPolicy');
    $router->add('/support/cookies-policy', 'support::cookiePolicy');
    $router->add('/support/public-sector-credit-account', 'public-sector-credit-account::index');
    $router->add('/support/about-partsit-com', 'about::index');
    
    $router->add('/consumers',   'index::consumers');
    $router->add('/maintenance', 'index::maintenance');
    $router->add('/end-users',   'index::endUsers');
    $router->add('/government',  'index::government');
    $router->add('/brokers',     'index::brokers');
    
    $router->add('/categories-ajax/{sectionURL:[a-z0-9\-]+}',                           'categories-ajax::section');
    $router->add('/categories-ajax/{sectionURL:[a-z0-9\-]+}/{categoryURL:[a-z0-9\-]+}', 'categories-ajax::category');
    
    /* chat.chat route */
    $router->add('/chat/{chatID:[0-9]+}', 'chat::chat');
    
    /* product route */
    $router->add('/product/{partURL:[a-z0-9\-]+}',               'product::product');
    $router->add('/product/{partURL:[a-z0-9\-]+}/email',         'product::email');
    $router->add('/product/{partURL:[a-z0-9\-]+}/request-price', 'product::requestPrice');
    $router->add('/product/{partURL:[a-z0-9\-]+}/review',        'product::review');
    $router->add('/product/{partURL:[a-z0-9\-]+}/email-example', 'product::emailExample');
    $router->add('/product/{partURL:[a-z0-9\-]+}/refurb',      'product::refurb');
    
    $router->add(
      '/product/{partURL:[a-z0-9\-]+}/admin/([a-zA-Z0-9\-]+)',
      array(
        'controller' => 'product-admin',
        'action'     => 2
      )
    );
 
    /* products route */
    $router->add('/products/{partURL:[a-z0-9\-]+}',               'product::product');
    $router->add('/products/{partURL:[a-z0-9\-]+}/email',         'product::email');
    $router->add('/products/{partURL:[a-z0-9\-]+}/request-price', 'product::requestPrice');
    $router->add('/products/{partURL:[a-z0-9\-]+}/review',        'product::review');
    $router->add('/products/{partURL:[a-z0-9\-]+}/email-example', 'product::emailExample');
    
    $router->add(
      '/products/{partURL:[a-z0-9\-]+}/admin/([a-zA-Z0-9\-]+)',
      array(
        'controller' => 'product-admin',
        'action'     => 2
      )
    );
 
    $router->add('/resources/image/{hash:[a-zA-Z0-9\-]+}', 'resources::image');
    $router->add('/resources/blob/{partID:[0-9]+}', 'resources::blob');
        
        $router->add('/background/alibaba/{partURL:[a-z0-9\-]+}',    'background::alibaba');
    
    $router->add('/reviews/{partURL:[a-z0-9\-]+}',               'reviews::product');
    
    /* part-finder routes */
    $router->add('/part-finder/{systemManufacturerURL:[a-z0-9\-]+}',                                                                                     'part-finder::manufacturer');
    $router->add('/part-finder/{systemManufacturerURL:[a-z0-9\-]+}/{modelFamilyURL:[a-z0-9\-]+}',                                                        'part-finder::modelFamily');
    $router->add('/part-finder/{systemManufacturerURL:[a-z0-9\-]+}/{modelFamilyURL:[a-z0-9\-]+}/{modelNumberURL:[a-z0-9\-]+}',                           'part-finder::modelNumber');
    $router->add('/part-finder/{systemManufacturerURL:[a-z0-9\-]+}/{modelFamilyURL:[a-z0-9\-]+}/{modelNumberURL:[a-z0-9\-]+}/{oldCategorySlug:[a-z-]+}', 'part-finder::modelNumber');
    $router->add('/part-finder/search',                                                                                                                  'part-finder::search');
    
    $router->add('/account/returns/{pageNumber:[0-9]+}',          'account::returns');
    
    $router->add('/account/previous-purchases/{pageNumber:[0-9]+}',          'account::previousPurchases');
    $router->add('/account/quotes/{pageNumber:[0-9]+}',                      'account::quotes');
    $router->add('/account/invoices/{pageNumber:[0-9]+}',                    'account::invoices');
    
    /* part-finder admin routes */
    $router->add('/dashboard/part-finder/{systemManufacturerURL:[a-z0-9\-]+}',                                                           'dashboard::partFinderManufacturer');
    $router->add('/dashboard/part-finder/{systemManufacturerURL:[a-z0-9\-]+}/{modelFamilyURL:[a-z0-9\-]+}',                              'dashboard::partFinderModelFamily');
    $router->add('/dashboard/part-finder/{systemManufacturerURL:[a-z0-9\-]+}/{modelFamilyURL:[a-z0-9\-]+}/{modelNumberURL:[a-z0-9\-]+}', 'dashboard::partFinderModelNumber');
    
    $router->add('/dashboard/categories/{sectionURL:[a-z0-9\-]+}',                                                        'dashboard::categoriesSection');
    $router->add('/dashboard/categories/{sectionURL:[a-z0-9\-]+}/{categoryURL:[a-z0-9\-]+}',                              'dashboard::categoriesCategory');
    
    $router->add('/dashboard/promo/{page:[0-9]+}', 'dashboard::promo');
    $router->add('/dashboard/pending-orders/{page:[0-9]+}', 'dashboard::pendingOrders');
    $router->add('/dashboard/pending-orders/{page:[0-9]+}/{orderDirection:[0-1]{1}}', 'dashboard::pendingOrders');
 
    $router->add('/api/xml/all', 'api::xmlAll');
 
    $router->add('/dashboard/feedback/{pageNumber:[0-9]+}',      'dashboard::feedback');
    $router->add('/dashboard/feedback/add',                      'dashboard::feedbackAdd');
    $router->add('/dashboard/feedback/edit/{feedbackID:[0-9]+}', 'dashboard::feedbackEdit');
    
    //TODO
    $router->add('/dashboard/email-shots/new', 'dashboard::emailShotsNew');
    $router->add('/dashboard/approve-images/{s:[A-Za-z0-9]+}', 'dashboard::approveImages');
    
    $router->add('/dashboard/parts/add',                             'dashboard::partsAdd');
    $router->add('/dashboard/parts/modify/{partURL:[A-Za-z0-9\-]+}', 'dashboard::partsModify');
    
    $router->add('/dashboard/accounts/{pageNumber:[0-9]+}',          'dashboard::accounts');
    $router->add('/dashboard/accounts/orders/{customerID:[0-9]+}',   'dashboard::accountsOrders');
    $router->add('/dashboard/accounts/rmas/{customerID:[0-9]+}',     'dashboard::accountsRmas');
    
    $router->add('/dashboard/survey/add', 'dashboard::surveyAdd');
    $router->add('/dashboard/newsletter-subscribers/{page:[0-9]+}', 'dashboard::newsletterSubscribers');
    
    $router->add('/dashboard/carousel/add',                        'dashboard::carouselAdd');
    $router->add('/dashboard/carousel/edit/{carouselID:[0-9]+}',   'dashboard::carouselEdit');
    $router->add('/dashboard/carousel/delete/{carouselID:[0-9]+}', 'dashboard::carouselDelete');
    
    $router->add('/dashboard/online-users/{pageNumber:[0-9]+}', 'dashboard::onlineUsers');
    
    $router->add('/dashboard/reviews/{pageNumber:[0-9]+}', 'dashboard::reviews');
    
    $router->add('/dashboard/part-images/{pageNumber:[0-9]+}', 'dashboard::partImages');
    
    $router->add('/dashboard/pending-orders/search/{pendingOrderID:[0-9]+}', 'dashboard::pendingOrdersSingle');
    
    $router->add('/dashboard/showcases/edit/{showcaseURL:[a-z0-9\-]+}', 'dashboard::showcasesEdit');
    
    $router->add('/manufacturers/{letter:[a-z]}',                     'manufacturers::letter');
    
    /* manufacturer */
    $router->add('/manufacturer/{manufacturerURL:[a-z0-9\-]+}',                     'manufacturer::manufacturer');
    $router->add('/manufacturer/{manufacturerURL:[a-z0-9\-]+}/{pageNumber:[0-9]+}', 'manufacturer::manufacturer');
    
    /* category routes. */
    $router->add('/category/{sectionURL:[a-z0-9\-]+}',                                                                            'category::section');
    $router->add('/category/{sectionURL:[a-z0-9\-]+}/{categoryURL:[a-z0-9\-]+}',                                                  'category::category');
    $router->add('/category/{sectionURL:[a-z0-9\-]+}/{categoryURL:[a-z0-9\-]+}/{subCategoryURL:[a-z0-9\-]+}',                     'category::subCategory');
    $router->add('/category/{sectionURL:[a-z0-9\-]+}/{categoryURL:[a-z0-9\-]+}/{subCategoryURL:[a-z0-9\-]+}/{pageNumber:[0-9]+}', 'category::subCategory');
    
    /* basket.add routes. */
    $router->add('/basket/add/{partURL:[a-z0-9\-]+}',                   'basket::add');
    $router->add('/basket/add/{partURL:[a-z0-9\-]+}/{quantity:[0-9]+}', 'basket::add');
    $router->add('/basket/add-bundle/{partBundleID:[0-9]+}',            'basket::addBundle');
    
    /* basket.remove */
    $router->add('/basket/remove/{partURL:[a-z0-9\-]+}', 'basket::remove');
    
    $router->add('/feedback/{pageNumber:[0-9]+}', 'feedback::index');
    
    $router->add('/returns/{orderID:[a-zA-Z0-9\-]+}',        'returns::return');
    $router->add('/returns/{orderID:[a-zA-Z0-9\-]+}/submit', 'returns::submit');
    
    $router->add('/res/css/{cssFile:[A-Za-z0-9\-\.]+}', 'res::css');
    $router->add('/res/js/{jsFile:[A-Za-z0-9\-\.]+}',   'res::js');
    
    $router->add('/review/{reviewID:[0-9]+}/helpful',   'reviews::helpful');
    $router->add('/review/{reviewID:[0-9]+}/unhelpful', 'reviews::unhelpful');
    
    $router->add('/survey/{surveyURL:[A-Za-z0-9-]+}', 'survey::survey');
    
    /* dashboard.staff-ips routes. */
    $router->add('/dashboard/staff-ips/add',                               'dashboard::staffIpsAdd');
    $router->addPost('/background/update-staff-ip-status',                 'dashboard::updateIPStatus');
    $router->add('/dashboard/staff-ips/edit/{staffIpURL:[A-Za-z0-9-]+}',   'dashboard::staffIpsEdit');
    $router->add('/dashboard/staff-ips/delete/{staffIpURL:[A-Za-z0-9-]+}', 'dashboard::staffIpsDelete');
    
    $router->add('/showcase/{showcaseURL:[a-z0-9\-]+}', 'showcase::showcase');
    
    $router->add('/sitemap/xml/pages',                     'sitemap::xmlPages');
    $router->add('/sitemap/xml/manufacturers',             'sitemap::xmlManufacturers');
    $router->add('/sitemap/xml/parts/{pageNumber:[0-9]+}', 'sitemap::xmlParts');
    
    $router->add('/guides/{guideURL:[A-Za-z0-9-]+}', 'guides::guide');
    
    $router->add('/api/xml/{page:[0-9]+}', 'api::xml');
    
    $router->add('/clearance/{manufacturerURL:[A-Za-z0-9-]+}',                     'clearance::manufacturer');
    $router->add('/clearance/{manufacturerURL:[A-Za-z0-9-]+}/{pageNumber:[0-9]+}', 'clearance::manufacturer');
    
    $router->add('/tracking/{orderID:[0-9]+}', 'tracking::details');
    
    return $router;
  }
);
 
// Handle the request.
$application = new \Phalcon\Mvc\Application($di);
 
$eventsManager = new \Phalcon\Events\Manager();
$application->setEventsManager($eventsManager);
 
$eventsManager->attach("application:boot", new \PhalconHelpers\ServiceProvider\Aws(
  array(
    'region' => 'eu-west-1'
  )
));
 
echo $application->handle()->getContent();
 
// Just in case there's nothing to commit.
try {
  $logger->commit();
} catch (\Exception $e) {
  
}
#4require_once(/home/ubuntu/partsit-site/app/web.php)
/home/ubuntu/partsit-site/public/index.php (3)
<?php
 
require_once '../app/web.php';
KeyValue
_url/category/networking/telecommunications/gps-products
KeyValue
USERwww-data
HOME/var/www
FCGI_ROLERESPONDER
QUERY_STRING_url=/category/networking/telecommunications/gps-products
REQUEST_METHODGET
CONTENT_TYPE
CONTENT_LENGTH
SCRIPT_FILENAME/home/ubuntu/partsit-site/public/index.php
SCRIPT_NAME/index.php
REQUEST_URI/category/networking/telecommunications/gps-products
DOCUMENT_URI/index.php
DOCUMENT_ROOT/home/ubuntu/partsit-site/public
SERVER_PROTOCOLHTTP/1.1
GATEWAY_INTERFACECGI/1.1
SERVER_SOFTWAREnginx/1.4.6
REMOTE_ADDR172.31.40.162
REMOTE_PORT27305
SERVER_ADDR172.31.47.41
SERVER_PORT443
SERVER_NAMEwww.partsit.com
HTTPSon
REDIRECT_STATUS200
PATH_INFO
PATH_TRANSLATED/home/ubuntu/partsit-site/public
HTTP_HOSTwww.partsit.com
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODINGx-gzip, gzip, deflate
HTTP_USER_AGENTCCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_X_FORWARDED_FOR54.198.147.221
HTTP_X_FORWARDED_PORT443
HTTP_X_FORWARDED_PROTOhttps
HTTP_CONNECTIONkeep-alive
PHP_SELF/index.php
REQUEST_TIME_FLOAT1500835955.8511
REQUEST_TIME1500835955
#Path
0/home/ubuntu/partsit-site/public/index.php
1/home/ubuntu/partsit-site/app/web.php
2/home/ubuntu/partsit-site/app/startup.php
3/home/ubuntu/partsit-site/vendor/autoload.php
4/home/ubuntu/partsit-site/vendor/composer/autoload_real.php
5/home/ubuntu/partsit-site/vendor/composer/ClassLoader.php
6/home/ubuntu/partsit-site/vendor/composer/include_paths.php
7/home/ubuntu/partsit-site/vendor/composer/autoload_namespaces.php
8/home/ubuntu/partsit-site/vendor/composer/autoload_psr4.php
9/home/ubuntu/partsit-site/vendor/composer/autoload_classmap.php
10/home/ubuntu/partsit-site/vendor/composer/autoload_files.php
11/home/ubuntu/partsit-site/vendor/guzzlehttp/promises/src/functions_include.php
12/home/ubuntu/partsit-site/vendor/guzzlehttp/promises/src/functions.php
13/home/ubuntu/partsit-site/vendor/guzzlehttp/psr7/src/functions_include.php
14/home/ubuntu/partsit-site/vendor/guzzlehttp/psr7/src/functions.php
15/home/ubuntu/partsit-site/vendor/guzzlehttp/guzzle/src/functions_include.php
16/home/ubuntu/partsit-site/vendor/guzzlehttp/guzzle/src/functions.php
17/home/ubuntu/partsit-site/vendor/mtdowling/jmespath.php/src/JmesPath.php
18/home/ubuntu/partsit-site/vendor/aws/aws-sdk-php/src/functions.php
19/home/ubuntu/partsit-site/vendor/swiftmailer/swiftmailer/lib/swift_required.php
20/home/ubuntu/partsit-site/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php
21/home/ubuntu/partsit-site/vendor/ircmaxell/password-compat/lib/password.php
22/home/ubuntu/partsit-site/vendor/symfony/polyfill-php55/bootstrap.php
23/home/ubuntu/partsit-site/vendor/symfony/polyfill-php54/bootstrap.php
24/home/ubuntu/partsit-site/vendor/react/promise/src/functions_include.php
25/home/ubuntu/partsit-site/vendor/react/promise/src/functions.php
26/home/ubuntu/partsit-site/vendor/symfony/polyfill-mbstring/bootstrap.php
27/home/ubuntu/partsit-site/vendor/illuminate/support/Illuminate/Support/helpers.php
28/home/ubuntu/partsit-site/app/library/PhalconHelpers/ServiceProvider/Aws.php
29/home/ubuntu/partsit-site/app/controllers/CategoryController.php
30/home/ubuntu/partsit-site/app/controllers/ControllerBase.php
31/home/ubuntu/partsit-site/app/library/Auth.php
32/home/ubuntu/partsit-site/app/models/StaffIPs.php
33/home/ubuntu/partsit-site/app/models/BaseModel.php
34/home/ubuntu/partsit-site/app/models/Baskets.php
35/home/ubuntu/partsit-site/app/models/ExchangeRates.php
36/home/ubuntu/partsit-site/app/models/Sections.php
37/home/ubuntu/partsit-site/app/models/Metadata.php
38/home/ubuntu/partsit-site/app/models/Manufacturers.php
39/home/ubuntu/partsit-site/app/models/SystemManufacturers.php
40/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/MD5.php
41/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/IPv4.php
42/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/URLSlug.php
43/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/Description.php
44/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/Month.php
45/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/DellServiceTag.php
46/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/HPProductNumber.php
47/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/LenovoSerialNumber.php
48/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/CreditCardNumber.php
49/home/ubuntu/partsit-site/app/library/PhalconHelpers/Filters/Name.php
50/home/ubuntu/partsit-site/app/models/SubCategories.php
51/home/ubuntu/partsit-site/app/models/Categories.php
Memory
Usage1835008