Phalcon Framework 2.0.9

Exception: fasdf

/home/ubuntu/partsit-site/app/models/ModelFamilies.php (51)
#0Models\ModelFamilies::findFromURL(category, peripherals)
/home/ubuntu/partsit-site/app/models/ModelNumbers.php (49)
<?php
 
namespace Models;
 
class ModelNumbers extends BaseModel
{
  protected $modelNumberID;
  protected $modelNumber;
  protected $modelFamilyID;
  protected $modelNumberURL;
  
  
  
  public function initialize()
  {
    $this->useDynamicUpdate(true);
    
    
    
    $this->belongsTo(
      'modelFamilyID',
      '\Models\ModelFamilies',
      'modelFamilyID',
      array(
        'alias' => 'ModelFamilies'
      )
    );
    
    $this->hasMany(
      'modelNumberID',
      '\Models\CompatibleParts',
      'modelNumberID',
      array(
        'foreignKey' => array(
          'message' => 'The model number has children.'
        ),
        'alias' => 'CompatibleParts'
      )
    );
  }
  
  
  
  public static function findFromURL($systemManufacturerURL, $modelFamilyURL, $modelNumberURL)
  {
    $modelFamily = \Models\ModelFamilies::findFromURL(
      $systemManufacturerURL,
      $modelFamilyURL
    );
    
    if (!$modelFamily) {
      throw new \Exception('fasdf');
    }
    
    $modelNumber = \Models\ModelNumbers::findFirst(
      array(
        'modelFamilyID = :modelFamilyID:
        AND
        modelNumberURL = :modelNumberURL:',
        'bind' => array(
          'modelFamilyID'  => $modelFamily->getModelFamilyID(),
          'modelNumberURL' => $modelNumberURL
        )
      )
    );
    
    return $modelNumber;
  }
  
  
  
  
  public function afterSave()
  {
    $elasticSearch = \Phalcon\DI::getDefault()->get('elasticSearch');
    
    $modelNumber        = $this;
    $modelFamily        = $modelNumber->getModelFamilies();
    $systemManufacturer = $modelFamily->getSystemManufacturers();
    
    $body = array(
      'systemManufacturer' => $systemManufacturer->getSystemManufacturer(),
      'modelFamily'        => $modelFamily->getModelFamily(),
      'modelNumber'        => $this->getModelNumber()
    );
    
    $elasticSearch->index(
      array(
        'index' => 'partsit',
        'type'  => 'modelNumbers',
        'id'    => $this->getModelNumberID(),
        'body'  => $body
      )
    );
  }
  
  
  public static function search($query, $pageNumber = 1, $itemsPerPage = 20)
  {
    $startIndex = (($pageNumber - 1) * $itemsPerPage);
    
    $body = array(
      'query' => array(
        'query_string' => array(
          'query'            => $query,
          'default_operator' => 'and'
        )
      ),
      'facets' => array(
        'tag' => array(
          'terms' => array(
            'field' => 'tag',
            'size'  => 10,
            'order' => 'term'
          )
        )
      ),
      'from' => $startIndex,
      'size' => $itemsPerPage
    );
    
    $elasticSearch = \Phalcon\DI::getDefault()->get('elasticSearch');
    
    $results = $elasticSearch->search(
      array(
        'index' => 'partsit',
        'type'  => 'modelNumbers',
        'body'  => $body
      )
    );
    
    $techSpecs = array();
    
    $modelNumbers = $results['hits']['hits'];
    
    foreach ($modelNumbers as $i => $modelNumber) {
      $modelNumbers[$i] = \Models\ModelNumbers::findFirst(
        array(
          'modelNumberID = :modelNumberID:',
          'bind' => array(
            'modelNumberID' => $modelNumber['_id']
          )
        )
      );
    }
    
    return array(
      'query'        => $query,
      'pageNumber'   => $pageNumber,
      'itemsPerPage' => $itemsPerPage,
      'totalResults' => $results['hits']['total'],
      'modelNumbers' => $modelNumbers
    );
  }
  
  
  
  
  
  
  
  public function getModelNumberID()
  {
    return $this->modelNumberID;
  }
  
  public function getModelNumber()
  {
    return $this->modelNumber;
  }
  
  public function getModelFamilyID()
  {
    return $this->modelFamilyID;
  }
  
  public function getModelNumberURL()
  {
    return $this->modelNumberURL;
  }
  
  
  
  public function setModelNumber($modelNumber)
  {
    $this->modelNumber = $modelNumber;
  }
  
  public function setModelFamilyID($modelFamilyID)
  {
    $this->modelFamilyID = $modelFamilyID;
  }
  
  public function setModelNumberURL($modelNumberURL)
  {
    $this->modelNumberURL = $modelNumberURL;
  }
  
  
  
  
  
  
  
  public function getModelFamilies($parameters = array())
  {
    if (isset($parameters[0])) {
      $parameters[0] = '(' . $parameters[0] . ') AND modelFamilyID = :modelFamilyID:';
    } else {
      $parameters[0] = 'modelFamilyID = :modelFamilyID:';
    }
    
    if (!isset($parameters['bind'])) {
      $parameters['bind'] = array();
    }
    
    $parameters['bind']['modelFamilyID'] = $this->getModelFamilyID();
    
    $parameters['cache'] = array(
      'key'      => 'modelFamilies:id:' . $this->getModelFamilyID(),
      'lifetime' => 604800 // 1 week
    );
    
    $section = \Models\ModelFamilies::findFirst(
      $parameters
    );
    
    return $section;
  }
}
#1Models\ModelNumbers::findFromURL(category, peripherals, printers-faxes)
/home/ubuntu/partsit-site/app/controllers/PartFinderController.php (423)
<?php
 
namespace Controllers;
 
class PartFinderController extends \Controllers\ControllerBase
{
  public function indexAction()
  {
    if ($this->request->getPost('manufacturer') && $this->request->getPost('serialNumber')) {
      $manufacturer = $this->request->getPost('manufacturer');
      
      if ($manufacturer == 'dell') {
        $serviceTag = $this->request->getPost('serialNumber', 'dellServiceTag');
        
        return $this->response->redirect(
          'part-finder/dell?serviceTag=' . $serviceTag
        );
      } elseif ($manufacturer == 'hp') {
        $serialNumber = $this->request->getPost('serialNumber', 'hpProductNumber');
        
        return $this->response->redirect(
          'part-finder/hp?serialNumber=' . $serialNumber
        );
      } elseif ($manufacturer == 'lenovo') {
        $serialNumber = $this->request->getPost('serialNumber', 'lenovoSerialNumber');
        
        return $this->response->redirect(
          'part-finder/lenovo?serialNumber=' . $serialNumber
        );
      }
    }
    
    
    
    $systemManufacturers = \Models\SystemManufacturers::find(
      array(
        'order' => 'systemManufacturer ASC'
      )
    );
    
    
    
    $this->view->systemManufacturers = $systemManufacturers;
    
    
    
    $this->tag->prependTitle(
      'Part Finder | '
    );
  }
  
  
  
  public function searchAction()
  {
    $query      = $this->request->getQuery('q');
    $pageNumber = $this->request->getQuery('pageNumber') ?: 1;
    
    $itemsPerPage = 20;
    
    
    
    if (!$query) {
      return $this->response->redirect(
        'part-finder'
      );
    }
    
    
    
    $results = \Models\ModelNumbers::search(
      $query,
      $pageNumber,
      $itemsPerPage
    );
    
    
    
    if ($results['totalResults'] == 1 && $pageNumber == 1) {
      $modelNumber        = $results['modelNumbers'][0];
      $modelFamily        = $modelNumber->getModelFamilies();
      $systemManufacturer = $modelFamily->getSystemManufacturers();
      
      return $this->response->redirect(
        'part-finder/' . $systemManufacturer->getSystemManufacturerURL() . '/' . $modelFamily->getModelFamilyURL() . '/' . $modelNumber->getModelNumberURL()
      );
    }
    
    
    $totalResults = $results['totalResults'];
    
    
    
    $this->view->query        = $query;
    $this->view->modelNumbers = $results['modelNumbers'];
    
    $this->view->pageNumber = $pageNumber;
    
    
    
    $this->view->pagination = array(
      'pageNumber'   => $pageNumber,
      'itemsPerPage' => $itemsPerPage,
      'totalItems'   => $totalResults,
      'url'          => '/part-finder/search?q=' . urlencode($query)  . '&pageNumber=',
      'what'         => 'model number'
    );
    
    
    
    $this->tag->prependTitle(
      'Part Finder Search | '
    );
  }
  
  
  
  public function manufacturerAction()
  {
    $systemManufacturerURL = $this->dispatcher->getParam('systemManufacturerURL');
    
    
    
    if (strtolower($systemManufacturerURL) == 'asus') {
      if ($this->request->getQuery('serviceTag', 'string')) {
        //TODO
      }
    } elseif (strtolower($systemManufacturerURL) == 'dell') {
      if ($this->request->getQuery('serviceTag', 'string')) {
        $dellAPI = new \Apis\Dell\ServiceTag();
        
        //TODO Use the dellServiceTag filter.
        $serviceTag = $this->request->getQuery('serviceTag', 'string');
        
        $this->view->serviceTag = strtoupper($serviceTag);
        $this->view->machine    = $dellAPI->find($serviceTag);
      }
    } elseif (strtolower($systemManufacturerURL) == 'hp') {
      if ($this->request->getQuery('productNumber', 'string')) {
        $hpAPI = new \Apis\HP\PartSurfer();
        
        //TODO Use the hpProductNumber filter.
        $productNumber = $this->request->getQuery('productNumber', 'string');
        
        $partSurfer = $hpAPI->search($productNumber);
        
        $this->view->productNumber = strtoupper($productNumber);
        $this->view->machine       = $partSurfer['machine'];
      }
    } elseif (strtolower($systemManufacturerURL) == 'lenovo') {
      if ($this->request->getQuery('serialNumber', 'string')) {
        $lenovoAPI = new \Apis\Lenovo\PartsLookup();
        
        //TODO Use the lenovoSerialNumber filter.
        $serialNumber = $this->request->getQuery('serialNumber', 'string');
        
        $this->view->serialNumber = strtoupper($serialNumber);
        $this->view->machine      = $lenovoAPI->find($serialNumber);
      }
    }
    
    
    
    $systemManufacturer = \Models\SystemManufacturers::findFromURL(
      $systemManufacturerURL
    );
    
    if (!$systemManufacturer) {
      return $this->error404();
    }
    
    
    
    $modelFamilies = $systemManufacturer->getModelFamilies(
      array(
        'order' => 'modelFamily'
      )
    );
    
    
    
    $this->view->systemManufacturer = $systemManufacturer;
    $this->view->modelFamilies      = $modelFamilies;
    
    
    
    $this->tag->prependTitle(
      $systemManufacturer->getSystemManufacturer() . ' Parts | '
    );
  }
  
  public function modelFamilyAction()
  {
    $systemManufacturerURL = $this->dispatcher->getParam('systemManufacturerURL');
    $modelFamilyURL        = $this->dispatcher->getParam('modelFamilyURL');
    
    
    
    $modelFamily = \Models\ModelFamilies::findFromURL(
      $systemManufacturerURL,
      $modelFamilyURL
    );
    
    if (!$modelFamily) {
      return $this->error404();
    }
    
    
    
    $systemManufacturer = $modelFamily->getSystemManufacturers();
    
    $modelNumbers = $modelFamily->getModelNumbers(
      array(
        'order' => 'modelNumber'
      )
    );
    
    
    
    $this->view->systemManufacturer = $systemManufacturer;
    $this->view->modelFamily        = $modelFamily;
    $this->view->modelNumbers       = $modelNumbers;
    
    
    
    $this->tag->prependTitle(
      $systemManufacturer->getSystemManufacturer() . ' ' . $modelFamily->getModelFamily() . ' Parts | '
    );
  }
  
  
  
  public function modelNumberAction()
  {
    //TODO
    $oldCategorySlugs = array(
      // 'ac-adapter'                                 => 0000000000000000000,
      // 'access-point'                               => 0000000000000000000,
      // 'accessories'                                => 0000000000000000000,
      // 'adapters'                                   => 0000000000000000000,
      // 'audio-board'                                => 0000000000000000000,
      // 'audio-visual'                               => 0000000000000000000,
      // 'back-up'                                    => 0000000000000000000,
      // 'bags'                                       => 0000000000000000000,
      // 'base-assembly'                              => 0000000000000000000,
      // 'base-cover-assemblies'                      => 0000000000000000000,
      // 'base-cover-assembly'                        => 0000000000000000000,
      // 'base-cover-palm-rest'                       => 0000000000000000000,
      // 'base-covers'                                => 0000000000000000000,
      // 'base-units'                                 => 0000000000000000000,
      // 'batteries'                                  => 0000000000000000000,
      // 'bezels'                                     => 0000000000000000000,
      // 'boards'                                     => 0000000000000000000,
      // 'brackets'                                   => 0000000000000000000,
      // 'cables'                                     => 0000000000000000000,
      // 'card-reader'                                => 0000000000000000000,
      // 'case-parts-doors-plastics'                  => 0000000000000000000,
      // 'cases-products'                             => 0000000000000000000,
      // 'cctv'                                       => 0000000000000000000,
      // 'cd-dvd'                                     => 0000000000000000000,
      // 'chassis'                                    => 0000000000000000000,
      // 'consumer-cameras'                           => 0000000000000000000,
      // 'consumer-electronics'                       => 0000000000000000000,
      // 'controller-cards'                           => 0000000000000000000,
      // 'covers'                                     => 0000000000000000000,
      // 'cpu-processor'                              => 0000000000000000000,
      'das'                                        => 56,
      // 'desktops'                                   => 0000000000000000000,
      // 'dictation'                                  => 0000000000000000000,
      // 'digital-imaging'                            => 0000000000000000000,
      // 'displays-screens'                           => 0000000000000000000,
      // 'docking-stations'                           => 0000000000000000000,
      // 'drives'                                     => 0000000000000000000,
      // 'fans'                                       => 0000000000000000000,
      // 'fans-heatsinks'                             => 0000000000000000000,
      'fax'                                        => 100,
      // 'firewall'                                   => 0000000000000000000,
      // 'flash-memory'                               => 0000000000000000000,
      // 'floppy-drives'                              => 0000000000000000000,
      // 'fuser'                                      => 0000000000000000000,
      // 'graphics-cards'                             => 0000000000000000000,
      // 'hard-drive-caddies-brackets-holders-cradle' => 0000000000000000000,
      // 'hard-drives'                                => 0000000000000000000,
      // 'hard-drives-external'                       => 0000000000000000000,
      // 'hinges'                                     => 0000000000000000000,
      // 'hinges-brackets'                            => 0000000000000000000,
      // 'hub'                                        => 0000000000000000000,
      // 'i-o-boards-and-controller-panels'           => 0000000000000000000,
      // 'inverter-boards'                            => 0000000000000000000,
      // 'io-boards'                                  => 0000000000000000000,
      // 'ip-cameras'                                 => 0000000000000000000,
      // 'joysticks'                                  => 0000000000000000000,
      'keyboards'                                  => 3,
      // 'kvm'                                        => 0000000000000000000,
      // 'kvm-switches'                               => 0000000000000000000,
      // 'laptops-products'                           => 0000000000000000000,
      // 'lcd-bezels'                                 => 0000000000000000000,
      // 'lcd-panels'                                 => 0000000000000000000,
      // 'lcd-screens-displays'                       => 0000000000000000000,
      // 'lcd-top-base-covers'                        => 0000000000000000000,
      // 'lcd-top-cover-back-cover'                   => 0000000000000000000,
      // 'maintenance'                                => 0000000000000000000,
      // 'media'                                      => 0000000000000000000,
      // 'media-converter'                            => 0000000000000000000,
      // 'memory-ram'                                 => 0000000000000000000,
      'mice'                                       => 4,
      // 'mics-headsets'                              => 0000000000000000000,
      // 'miscellaneous'                              => 0000000000000000000,
      // 'mobile-technology'                          => 0000000000000000000,
      // 'modem'                                      => 0000000000000000000,
      // 'monitors-products'                          => 0000000000000000000,
      // 'mother-boards'                              => 0000000000000000000,
      // 'nas-enclosures'                             => 0000000000000000000,
      // 'nas-solutions'                              => 0000000000000000000,
      // 'network-cards'                              => 0000000000000000000,
      // 'network-video-recorders'                    => 0000000000000000000,
      // 'networking'                                 => 0000000000000000000,
      // 'notebook-accessories'                       => 0000000000000000000,
      // 'notebook-computers'                         => 0000000000000000000,
      // 'optical-drives'                             => 0000000000000000000,
      // 'optical-drives-external'                    => 0000000000000000000,
      // 'optical-media'                              => 0000000000000000000,
      // 'palm-rest-touchpad'                         => 0000000000000000000,
      // 'palmrest-assemblies'                        => 0000000000000000000,
      // 'palmrest-touchpads'                         => 0000000000000000000,
      // 'panels'                                     => 0000000000000000000,
      // 'pc-accessories'                             => 0000000000000000000,
      // 'pc-components'                              => 0000000000000000000,
      // 'pc-nic'                                     => 0000000000000000000,
      // 'peripherals'                                => 0000000000000000000,
      // 'personal-computers'                         => 0000000000000000000,
      // 'plastics'                                   => 0000000000000000000,
      // 'power-boards-products'                      => 0000000000000000000,
      // 'power-cords'                                => 0000000000000000000,
      // 'power-distribution'                         => 0000000000000000000,
      // 'power-supply-units'                         => 0000000000000000000,
      // 'powerline'                                  => 0000000000000000000,
      // 'printers'                                   => 0000000000000000000,
      // 'projector'                                  => 0000000000000000000,
      // 'rack-mount-kits'                            => 0000000000000000000,
      // 'racks-and-accessories'                      => 0000000000000000000,
      // 'raid-arrays'                                => 0000000000000000000,
      // 'rdx'                                        => 0000000000000000000,
      // 'rollers'                                    => 0000000000000000000,
      // 'routers'                                    => 0000000000000000000,
      // 'sanraiddisk-arrays'                         => 0000000000000000000,
      // 'scanners'                                   => 0000000000000000000,
      // 'screens-displays'                           => 0000000000000000000,
      // 'screws'                                     => 0000000000000000000,
      // 'security'                                   => 0000000000000000000,
      // 'security-and-environmental-monitoring'      => 0000000000000000000,
      // 'server-component'                           => 0000000000000000000,
      // 'server-components'                          => 0000000000000000000,
      // 'server-option'                              => 0000000000000000000,
      // 'software'                                   => 0000000000000000000,
      // 'speakers'                                   => 0000000000000000000,
      // 'speakers-ext'                               => 0000000000000000000,
      // 'speakers-internal'                          => 0000000000000000000,
      'ssd'                                        => 163,
      'ssd-consumer'                               => 163,
      'ssd-enterprise'                             => 163,
      // 'stands-mounts'                              => 0000000000000000000,
      // 'struxurewareinfrastruxure'                  => 0000000000000000000,
      // 'switches'                                   => 0000000000000000000,
      'tablet--pdas'                               => 16,
      'tablets-pdas'                               => 16,
      // 'tape'                                       => 0000000000000000000,
      // 'tape-autoloaders'                           => 0000000000000000000,
      'tape-drives'                                => 62,
      // 'tape-libraries'                             => 0000000000000000000,
      // 'tape-media'                                 => 0000000000000000000,
      // 'thermal-printer'                            => 0000000000000000000,
      // 'toners'                                     => 0000000000000000000,
      // 'top-base-covers'                            => 0000000000000000000,
      'uninterrruptible-power-supply-ups'          => 69,
      // 'usb-hubs'                                   => 0000000000000000000,
      'video-card'                                 => 15,
      // 'warranty'                                   => 0000000000000000000,
      // 'webcams'                                    => 0000000000000000000,
      // 'wireless-cards'                             => 0000000000000000000,
      // 'wireless-devices'                           => 0000000000000000000,
      // 'wireless-keyboards-mice'                    => 0000000000000000000,
      'workstation'                                => 37
    );
    
    
    
    $oldCategorySlug       = $this->dispatcher->getParam('oldCategorySlug');
    
    $systemManufacturerURL = $this->dispatcher->getParam('systemManufacturerURL');
    $modelFamilyURL        = $this->dispatcher->getParam('modelFamilyURL');
    $modelNumberURL        = $this->dispatcher->getParam('modelNumberURL');
    
    
    
    $pageNumber   = $this->request->getQuery('pageNumber', 'int', 1);
    $itemsPerPage = $this->request->getQuery('itemsPerPage', 'int', 10);
    
    
    
    if ($oldCategorySlug && array_key_exists($oldCategorySlug, $oldCategorySlugs)) {
      return $this->response->redirect(
        'part-finder/' . $systemManufacturerURL . '/' . $modelFamilyURL . '/' . $modelNumberURL . '?subCategory=' . $oldCategorySlugs[$oldCategorySlug],
        false,
        301
      );
    }
    
    
    
    $selectedSubCategoryID = $this->request->getQuery('subCategory', 'int');
    
    $selectedSubCategory = ($selectedSubCategoryID)
        ? \Models\SubCategories::findFirstBySubCategoryID($selectedSubCategoryID)
        : false;
    
    
    
    $modelNumber = \Models\ModelNumbers::findFromURL(
      $systemManufacturerURL,
      $modelFamilyURL,
      $modelNumberURL
    );
    
    if (!$modelNumber) {
      return $this->error404();
    }
    
    
    
    $query = $this->request->getQuery('q', 'trim');
    
    $searchParameters = array(
      $query,
      
      'modelNumber' => $modelNumber,
      
      'subCategory' => $selectedSubCategory,
      
      'sort'        => array(
        'category.section'     => 'ASC',
        'category.category'    => 'ASC',
        'category.subCategory' => 'ASC'
      )
    );
    
    
    
    $results = \Models\Parts::search(
      $searchParameters,
      $pageNumber,
      $itemsPerPage
    );
    
    $parts        = $results['parts'];
    $totalResults = $results['totalResults'];
    
    
    
    $results = \ArrayHelper::group(
      $parts,
      function ($part) {
        $subCategory = $part->getSubCategories();
        
        if ($subCategory) {
          $category = $subCategory->getCategories();
          $section  = $category->getSections();
          
          return ($section->getSection() . ' &gt; ' . $category->getCategory() . ' &gt; ' . $subCategory->getSubCategory());
        } else {
          return 'Unknown';
        }
      }
    );
    
    ksort($results);
    
    
    
    $modelFamily        = $modelNumber->getModelFamilies();
    $systemManufacturer = $modelFamily->getSystemManufacturers();
    
    
    
    
    
    $filterSections      = \Models\Parts::searchDistinct('sectionID',     $searchParameters, 1000);
    $filterCategories    = \Models\Parts::searchDistinct('categoryID',    $searchParameters, 1000);
    $filterSubCategories = \Models\Parts::searchDistinct('subCategoryID', $searchParameters, 1000);
    
    
    
    
    $urlQueryString = http_build_query(
      array(
        'q'            => $query,
        
        'subCategory'  => $selectedSubCategoryID,
        
        'itemsPerPage' => $itemsPerPage,
        
        'pageNumber'   => ''
      ),
      null,
      '&amp;'
    );
    
    
    
    $this->view->filterSections      = $filterSections;
    $this->view->filterCategories    = $filterCategories;
    $this->view->filterSubCategories = $filterSubCategories;
    
    
    
    $this->view->selectedSubCategory = $selectedSubCategory;
    
    
    
    
    
    
    $this->view->systemManufacturer = $systemManufacturer;
    $this->view->modelFamily        = $modelFamily;
    $this->view->modelNumber        = $modelNumber;
    $this->view->results            = $results;
    
    $this->view->query              = $query;
    
    $this->view->itemsPerPage       = $itemsPerPage;
    
    
    
    $this->view->pagination = array(
      'pageNumber'   => $pageNumber,
      'itemsPerPage' => $itemsPerPage,
      'totalItems'   => $totalResults,
      'url'          => '/part-finder/' . $systemManufacturerURL . '/' . $modelFamilyURL . '/' . $modelNumberURL . '?' . $urlQueryString,
      'what'         => 'model number'
    );
    
    
    
    $this->tag->prependTitle(
      $systemManufacturer->getSystemManufacturer() . ' ' . $modelFamily->getModelFamily() . ' ' . $modelNumber->getModelNumber() . ' Parts | '
    );
  }
}
#2Controllers\PartFinderController->modelNumberAction(category, peripherals, printers-faxes, accessories)
#3Phalcon\Dispatcher->dispatch()
#4Phalcon\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) {
  
}
#5require_once(/home/ubuntu/partsit-site/app/web.php)
/home/ubuntu/partsit-site/public/index.php (3)
<?php
 
require_once '../app/web.php';
KeyValue
_url/part-finder/category/peripherals/printers-faxes/accessories
KeyValue
USERwww-data
HOME/var/www
FCGI_ROLERESPONDER
QUERY_STRING_url=/part-finder/category/peripherals/printers-faxes/accessories
REQUEST_METHODGET
CONTENT_TYPE
CONTENT_LENGTH
SCRIPT_FILENAME/home/ubuntu/partsit-site/public/index.php
SCRIPT_NAME/index.php
REQUEST_URI/part-finder/category/peripherals/printers-faxes/accessories
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.39.193
REMOTE_PORT29912
SERVER_ADDR172.31.16.243
SERVER_PORT443
SERVER_NAME
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_ENCODINGbr,gzip
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_X_FORWARDED_FOR34.231.21.83
HTTP_X_FORWARDED_PORT443
HTTP_X_FORWARDED_PROTOhttps
HTTP_CONNECTIONkeep-alive
PHP_SELF/index.php
REQUEST_TIME_FLOAT1590475651.4868
REQUEST_TIME1590475651
#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/PartFinderController.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/models/ModelNumbers.php
41/home/ubuntu/partsit-site/app/models/ModelFamilies.php
Memory
Usage1835008

Warning: Unknown: open(/var/lib/php5/sess_ofkopcajkob4frsok4o2j4pur5, O_RDWR) failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5) in Unknown on line 0