Phalcon Framework 4.1.2

Phalcon\Mvc\Model\Exception: The index does not exist in the cursor

phalcon/Mvc/Model/Resultset.zep (457)
#0Phalcon\Mvc\Model\Resultset->offsetGet
/home/xpatlink/apps/xpatweb/Xpatlink/Services/Categories.php (176)
<?php
use Phalcon\Di;
use Phalcon\DiInterface;
use Phalcon\Paginator\Adapter\Model;
 
 
class Categories{
 
 
 
  public function initialize()
  {
  
  }
 
  public function parent()
  {
    $sql         = "SELECT * FROM categories WHERE status = 1";
    $data       = \Phalcon\DI::getDefault()['connection']->query($sql);
    $data->setFetchMode(\Phalcon\Db\Enum::FETCH_OBJ);
    $results    = $data->fetchAll();
 
    return $results;
  }
 
 
  public function subcategories()
  {
    $sql         = "SELECT * FROM subcategories WHERE status = 1";
    $data       = \Phalcon\DI::getDefault()['connection']->query($sql);
    $data->setFetchMode(\Phalcon\Db\Enum::FETCH_OBJ);
    $results    = $data->fetchAll();
 
    return $results;
  }
 
 
  public function getMainImage($recordId)
  {
    $mainimage = array();
    $main_dir  = ADVERTS_PATH.'xpatlink__'.$recordId.'/'.'main/';
 
    $filetype = array();
        $filetype[] = 'jpg';
        $filetype[] = 'png';
        $filetype[] = 'jpeg';
        $filetype[] = 'JPG';
        $filetype[] = 'PNG';
        $filetype[] = 'JPEG';
 
 
        $_mainimage = scandir($main_dir);
        foreach ($_mainimage as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $mainimage[] = $file;
                }
            }
        }
 
        if (empty($mainimage)) {
          return false;
        }else{
          return $mainimage;
        }
        
  }
 
  public function getXtraImage($recordId)
  {
    $xtra = array();
    $xtra_dir  = ADVERTS_PATH.'xpatlink__'.$recordId.'/'.'extra/';
 
    $filetype = array();
        $filetype[] = 'jpg';
        $filetype[] = 'png';
        $filetype[] = 'jpeg';
        $filetype[] = 'JPG';
        $filetype[] = 'PNG';
        $filetype[] = 'JPEG';
 
 
        $_xtra = scandir($xtra_dir);
        foreach ($_xtra as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $xtra[] = $file;
                }
            }
        }
 
        if (empty($xtra)) {
          return false;
        }else{
          return $xtra;
        }
        
  }
 
 
  public function getLogoImage($recordId)
  {
    $logo = array();
    $logo_dir  = ADVERTS_PATH.'xpatlink__'.$recordId.'/'.'logo/';
 
    $filetype = array();
        $filetype[] = 'jpg';
        $filetype[] = 'png';
        $filetype[] = 'jpeg';
        $filetype[] = 'JPG';
        $filetype[] = 'PNG';
        $filetype[] = 'JPEG';
 
 
        $_logo = scandir($logo_dir);
        foreach ($_logo as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $logo[] = $file;
                }
            }
        }
 
        if (empty($logo)) {
          return false;
        }else{
          return $logo;
        }
        
  }
 
 
  public function getVideo($recordId)
  {
    $video = array();
    $video_dir  = ADVERTS_PATH.'xpatlink__'.$recordId.'/'.'video/';
        
    $filetype = array();
        $filetype[] = 'mp4';
        $filetype[] = 'MP4';
        $filetype[] = 'mov';
        $filetype[] = 'MOV';
        $filetype[] = 'wmv';
        $filetype[] = 'WMV';
        $filetype[] = 'avi';
        $filetype[] = 'AVI';
        $filetype[] = 'swf';
        $filetype[] = 'SWF';
 
  
        $_video = array_diff(scandir($video_dir), array('..', '.'));
   
        foreach ($_video as $file) {
             $video[] = $file;
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $video[] = $file;
                }
            }
        }
        if (empty($video)) {
          return false;
        }else{
          return $video;
        }
        
  }
 
 
 
 
  public function categoryCleanName($_category)
  {
 
    $categorymodel = new \Xpatlink\Modules\User\Models\Categories();
      $category = $categorymodel::find(['name LIKE "%'.$_category.'%"','LIMIT'=>1])[0]->name;
 
      return $category;
  }
 
    public function categoryMeta($_category)
    {
 
        $categorymodel = new \Xpatlink\Modules\User\Models\Categories();
        $category = $categorymodel::find(['name LIKE "%'.$_category.'%"','LIMIT'=>1])[0];
 
        return $category;
    }
 
    public function getCategoryPremiums($category)
    {
        $model = new \Xpatlink\Modules\User\Models\Xpatad();
        $status = 1;
 
        $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        $today = $today->format('Y-m-d H:i:s');
        $fdate = date('Y-m-d H:i:s', strtotime('-3 months'));
        return $model::find(['category ="'.$category.'" AND status ="'.$status.'" AND webpremium ="'.$status.'" AND date_created  > "'.$fdate.'"','order'=>'date_created DESC']);
    }
 
 
        public function getCategoryTops($category)
    {
        $model = new \Xpatlink\Modules\User\Models\Xpatad();
        $status = 1;
 
        $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        $today = $today->format('Y-m-d H:i:s');
        $fdate = date('Y-m-d H:i:s', strtotime('-3 months'));
        return $model::find(['category ="'.$category.'" AND status ="'.$status.'" AND webtop ="'.$status.'" AND date_created  > "'.$fdate.'"','order'=>'date_created DESC']);
    }
 
 
  public function getCategoryItems($category)
  {
    $model = new \Xpatlink\Modules\User\Models\Xpatad();
        $status = 1;
 
        $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        $today = $today->format('Y-m-d H:i:s');
 
        $fdate = date('Y-m-d H:i:s', strtotime('-3 months'));
 
 
        $now = date('Y-m-d h:i:s');
 
        $items = $model::find(['category ="'.$category.'" AND status ="'.$status.'" AND completed ="'.$status.'" AND date_created  > "'.$fdate.'"','order'=>'date_created DESC']);
 
        foreach ($items as $item) {
            $extended = $this->extended($item->id,$item->extendedduration,$item->date_created);
            $record = $model::findFirstById( $item->id);
            $record->listtime = $extended;
            $record->save();
        }
        
    #return $model::find(['category ="'.$category.'" AND status ="'.$status.'" AND completed ="'.$status.'" AND date_created  > "'.$fdate.'"','order'=>'date_created DESC']);
        $items=  $model::find(['category ="'.$category.'" AND listtime  > "'.$today.'"','order'=>'priority DESC, date_created DESC, id DESC']);
 
        #var_dump(count($items)); exit;
 
        return $items;
  }
 
    public function getPaginatedItems($category,$currentPage)
    {
        $model = new \Xpatlink\Modules\User\Models\Xpatad();
        $status = 1;
 
        $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        $today = $today->format('Y-m-d H:i:s');
 
        $fdate = date('Y-m-d H:i:s', strtotime('-3 months'));
 
 
        $now = date('Y-m-d h:i:s');
 
        $items = $model::find(['category ="'.$category.'" AND status ="'.$status.'" AND completed ="'.$status.'" AND date_created  > "'.$fdate.'"','order'=>'date_created DESC']);
 
        foreach ($items as $item) {
            $extended = $this->extended($item->id,$item->extendedduration,$item->date_created);
            $record = $model::findFirstById( $item->id);
            $record->listtime = $extended;
            $record->save();
        }
        
        #return $model::find(['category ="'.$category.'" AND status ="'.$status.'" AND completed ="'.$status.'" AND date_created  > "'.$fdate.'"','order'=>'date_created DESC']);
 
        $paginator   = new Model(
            [
                "model"      => $model,
                "parameters" => [
                    'conditions' => 'category = ?1 AND listtime > ?2 AND status = ?3',
                    'bind'       => [
                        1 => $category,2 => $today,3 =>1,
                    ],
                     "order" => 'priority DESC, date_created DESC, id DESC'
                ],
                "limit"      => 15,
                "page"       => $currentPage,
            ]
        );
 
        $items = $paginator->paginate();
 
        //$items=  $model::find(['category ="'.$category.'" AND listtime  > "'.$today.'"','order'=>'priority DESC, date_created DESC, id DESC']);
 
        #var_dump(count($items)); exit;
 
        return $items;
    }
 
 
 
    private function extended($id = null,$extendedduration,$date_created)
    {
        $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        $today = $today->format('Y-m-d H:i:s');
 
        $newdate = null;
 
         
 
            if( is_null($extendedduration) ||  $extendedduration == '' ){
              $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 15 days'));
            }else{
 
                
                switch ($extendedduration) {
                    case '15 days':
                        $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 30 days'));
 
                           #if ($id == 9018) {
                              #var_dump($date_created.' '.$newdate); exit;
                           # }
                        break;
                    case '20 days':
                        $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 45 days'));
                        break;
                    case '1 month':
                        $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 45 days'));
                        break;
                    case '2 months':
                        $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 75 days'));
                        break;
                    case '3 months':
                        $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 105 days'));
                        break;
                    
                    default:
                        # code...
                        break;
                }
 
              // if($extendedduration == '10 days'){
              //   $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 20 days'));
              // }
              // if($extendedduration == '15 days'){
              //   $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 15 days'));
              // }
              // if($extendedduration == '20 days'){
              //   $newdate =  date('Y-m-d h:i:s', strtotime($date_created. ' + 30 days'));
              // }
              // if($extendedduration == '1 month'){
              //   $newdate =  date('Y-m-d h:i:s', strtotime($date_created. '+1 months'));
              // }
              // if($extendedduration == '2 months'){
              //   $newdate =  date('Y-m-d h:i:s', strtotime($date_created. '+2 months'));
              // }
 
              // if($extendedduration == '3 months'){
              //   $newdate =  date('Y-m-d h:i:s', strtotime($date_created. '+3 months'));
              // }
 
            }
 
 
        return $newdate;
    }
 
  public function getCategoryTopbanner($category)
  {
 
        $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        //$today = $today->format('Y-m-d H:i:s');
        $today = $today->format('Y-m-d');
 
        // $today = $today.' 00:00:00';
 
        // $today = $today.' 00:00:00';
        // $lastday = $lastday.' 59:59:59';
 
    $model = new \Xpatlink\Modules\User\Models\Categorybanners();
    return $model::find(['category = "'.$category.'" AND position = "Top" AND startdate < "'.$today.'" AND enddate > "'.$today.'"','LIMIT'=>1]);
  }
 
  public function getCategoryRightbanner($category)
  {
 
 
            $today = new DateTime();
        $today->setTimezone(new DateTimeZone('Africa/Nairobi'));
        //$today = $today->format('Y-m-d H:i:s');
        $today = $today->format('Y-m-d');
        // $today = $today.' 00:00:00';
 
        // $today = $today.' 00:00:00';
        // $lastday = $lastday.' 59:59:59';
        
    $model = new \Xpatlink\Modules\User\Models\Categorybanners();
    return $model::find(['category = "'.$category.'" AND position = "Right" AND startdate <= "'.$today.'" AND enddate > "'.$today.'"']);
  }
 
 
    public function xpression()
    {
        $sql         = "SELECT * FROM categories WHERE xpression = 1";
        $data       = \Phalcon\DI::getDefault()['connection']->query($sql);
        $data->setFetchMode(\Phalcon\Db\Enum::FETCH_OBJ);
        $results    = $data->fetchAll();
 
        return $results;
    }
 
    public function xfood()
    {
        $sql         = "SELECT * FROM categories WHERE xfood = 1";
        $data       = \Phalcon\DI::getDefault()['connection']->query($sql);
        $data->setFetchMode(\Phalcon\Db\Enum::FETCH_OBJ);
        $results    = $data->fetchAll();
 
        return $results;
    }
 
    public function xdeal()
    {
        $sql         = "SELECT * FROM categories WHERE xdeal = 1";
        $data       = \Phalcon\DI::getDefault()['connection']->query($sql);
        $data->setFetchMode(\Phalcon\Db\Enum::FETCH_OBJ);
        $results    = $data->fetchAll();
 
        return $results;
    }
 
 
 
  
}
#1Categories->categoryCleanName
/home/xpatlink/apps/xpatweb/Xpatlink/Modules/User/controllers/CategoryController.php (57)
<?php
namespace Xpatlink\Modules\User\Controllers;
 use Phalcon\Paginator\Adapter\Model as PaginatorModel;
 
class CategoryController extends ControllerBase
{
 
    protected $currentPage;
    
  public function initialize()
  {
    date_default_timezone_set('Africa/Nairobi');
        $this->currentPage = isset($_GET["page"])?(int) $_GET["page"]:1;
 
  }
 
    public function indexAction()
    {
      #$categorymodel = new \Xpatlink\Modules\User\Models\Categories();
   // $_category = str_replace('-', ' ', $this->router->getControllerName());
   $_category = str_replace('-', ' ',  $this->dispatcher->getParam(0) );
 
    $category = $this->categories->categoryCleanName($_category);
 
    $webpremiums =  $this->categories->getCategoryPremiums($category);
    $webtops =  $this->categories->getCategoryTops($category);
 
    $items =  $this->categories->getCategoryItems($category);
    $topbanner = $this->categories->getCategoryTopbanner($category);
    $rightbanners = $this->categories->getCategoryRightbanner($category); 
 
     if (isset($topbanner)) {
         $this->view->topbanner = $topbanner;
     }
      if (isset($rightbanners)) {
         $this->view->rightbanners = $rightbanners;
     }
     $this->view->meta = $this->categories->categoryMeta($_category);
     $this->view->items = $this->getPagination($items);
    }
 
    public function viewAction()
    {
        $metamodel = new \Xpatlink\Modules\User\Models\Mainmeta();
 
        $_category = str_replace('-', ' ',  $this->dispatcher->getParam(0) );
 
 
 
        $_metadata =  $metamodel::find(['pagetitle LIKE "%'.$_category.'%"']);
 
        if (count($_metadata) > 0) {
           $this->view->metadata = $_metadata[0];
        }
 
 
        $category = $this->categories->categoryCleanName($_category);
 
 
        #var_dump($category); exit;
 
 
        #$webpremiums =  $this->categories->getCategoryPremiums($category);
        #$webtops =  $this->categories->getCategoryTops($category);
 
        $items =  $this->categories->getPaginatedItems($category,$this->currentPage);
 
        // foreach( $items as $item){
 
 
        //   if( $item->id  == 6513){
        //       var_dump($item->id); exit;
        //     }
        // }
        $topbanner = $this->categories->getCategoryTopbanner($category);
        $rightbanners = $this->categories->getCategoryRightbanner($category); 
 
        // var_dump($rightbanners[0]->image); exit;
 
        $meta = $this->categories->categoryMeta($_category);
 
       # $now = date('Y-m-d h:i:s');
 
 
        #var_dump(count($items));  exit;
        // foreach ($items as $item) {
 
        //     if( is_null($item->extendedduration) ||  $item->extendedduration == '' ){
        //       $newdate =  date('Y-m-d h:i:s', strtotime($item->date_created. ' + 10 days'));
        //     }else{
 
        //       if($item->extendedduration == '10 days'){
        //         $newdate =  date('Y-m-d h:i:s', strtotime($item->date_created. ' + 20 days'));
        //       }
        //       if($item->extendedduration == '20 days'){
        //         $newdate =  date('Y-m-d h:i:s', strtotime($item->date_created. ' + 30 days'));
        //       }
        //       if($item->extendedduration == '2 months'){
        //         $newdate =  date('Y-m-d h:i:s', strtotime($item->date_created. '+2 months'));
        //       }
 
        //       if($item->extendedduration == '3 months'){
        //         $newdate =  date('Y-m-d h:i:s', strtotime($item->date_created. '+3 months'));
        //       }
        //     }
 
        //     if( $newdate > $now ){
                
        //     }else{
                
        //     }
        // }
 
 
        #$nextpage = isset($_GET["page"])?(int) $_GET["page"]:1;
 
 
        #$hidenext = 0;
 
        // if ($nextpage > 1)  {
        //    $hidenext = 1;
        // }
        #$this->view->hidenext = $hidenext;
 
         if (isset($topbanner[0])) {
 
             $this->view->topbanner = $topbanner;
         }
          if (isset($rightbanners)) {
 
             $this->view->rightbanners = $rightbanners;
         }
         $this->view->meta = $meta;
         $this->view->_category = $this->dispatcher->getParam(0);
         $this->view->webpremiums = $webpremiums;
         $this->view->webtops = $webtops;
 
         $this->view->items = $items; //$this->getPagination($items);  
        
    }
 
 
    public function itemAction()
    {
        $model = new \Xpatlink\Modules\User\Models\Xpatad();
        $metamodel = new \Xpatlink\Modules\User\Models\Categorymeta();
        $itemId = $this->dispatcher->getParam(1);
        $item = $model::findFirstById($itemId);
 
        $logo_dir  = ADVERTS_PATH.'xpatlink__'.$item->id.'/'.'logo/';
        $main_dir  = ADVERTS_PATH.'xpatlink__'.$item->id.'/'.'main/';
        $extra_dir  = ADVERTS_PATH.'xpatlink__'.$item->id.'/'.'extra/';
        $video_dir  = ADVERTS_PATH.'xpatlink__'.$item->id.'/'.'video/';
 
        $filetype = array();
        $filetype[] = 'jpg';
        $filetype[] = 'png';
        $filetype[] = 'jpeg';
        $filetype[] = 'JPG';
        $filetype[] = 'PNG';
        $filetype[] = 'JPEG';
        $filetype[] = 'mp4';
        $filetype[] = 'MP4';
        $filetype[] = 'MOV';
        $filetype[] = 'mov';
        $filetype[] = 'WMV';
        $filetype[] = 'wmv';
        $filetype[] = 'AVI';
        $filetype[] = 'avi';
 
        $logo = $mainimage = $extraimages = $video = array();
 
        $_mainimage = scandir($main_dir);
        $_logo = scandir($logo_dir);
        $_extraimages = scandir($extra_dir);
        $_video = scandir($video_dir);
 
        foreach ($_mainimage as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $mainimage[] = $file;
                }
            }
        }
 
        foreach ($_logo as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $logo[] = $file;
                }
            }
        }
 
        foreach ($_extraimages as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $extraimages[] = $file;
                }
            }
        }
 
        foreach ($_video as $file) {
            foreach ($filetype as $extension) {
                if (strpos($file, $extension) !== false) {
                    $video[] = $file;
                }
            }
        }
 
        $this->view->mainimage = $mainimage;
        $this->view->logo = $logo;
        $this->view->extraimages = $extraimages;
        $this->view->video = $video;
 
 
        $_metadata =  $metamodel::find(['category LIKE "%'.$item->category.'%"']);
 
        if (count($_metadata) > 0) {
           $this->view->itemmeta = $_metadata[0];
        }
 
        $this->view->item = $item;
 
    }
 
 
 
    private function getPagination($model,$data)
    {
        // $paginator = new PaginatorModel(
        //     [
        //         "data"  => $data,
        //         "limit" => 15,
        //         "page"  => $this->currentPage,
        //     ]
        // );
 
        $page   = new PaginatorModel(
            [
                "model"      => $model,
                "parameters" => [
                    'conditions' => 'status = ?1',
                    'bind'       => [
                        1 => 0,
                    ],
                     "order" => 'id'
                ],
                "limit"      => 15,
                "page"       => $this->currentPage,
            ]
        );
 
 
        $page = $paginator->paginate();
 
        return $page;
    }
 
}
 
#2Xpatlink\Modules\User\Controllers\CategoryController->viewAction
#3Phalcon\Dispatcher\AbstractDispatcher->callActionMethod
#4Phalcon\Dispatcher\AbstractDispatcher->dispatch
#5Phalcon\Mvc\Application->handle
/home/xpatlink/apps/xpatweb/public/index.php (262)
<?php
// ini_set('display_errors', '1');
// ini_set('display_startup_errors', '1');
// error_reporting(E_ALL);
use Phalcon\Mvc\Router,
    Phalcon\Mvc\Application,
    Phalcon\DI\FactoryDefault,
    Phalcon\Security,
    Phalcon\Loader;
 
   
    use Phalcon\Logger;
    use Phalcon\Logger\Adapter\File as FileAdapter;
    use Phalcon\Http\Cookie;
    use Phalcon\Http\Response\Cookies;
    
    use Phalcon\Logger\Adapter\Stream;
 
    
 (new \Phalcon\Debug)->listen();
 
 
//echo phpinfo(); exit;
 
define('BASE_PATH', dirname(__DIR__));
define("BASE_URL", 'https://'. $_SERVER['HTTP_HOST']);
define('APP_PATH', BASE_PATH . '/Xpatlink');
define('HOMEIMAGE_PATH', BASE_PATH . '/public/images/homepage/');
define('CATEGORY_BANNER', BASE_PATH . '/public/images/categorybanners/');
define('MAGAZINE_PICTURE', BASE_PATH . '/public/images/issues/');
define('ADVERTS_PATH', BASE_PATH . '/public/images/xpatlink/');
define('ADTESTS_PATH', BASE_PATH . '/public/images/xpatlinktest/');
define('EVENTS_PATH', BASE_PATH . '/public/images/events/');
define('XPRESSION_PATH', BASE_PATH . '/public/images/xpression/');
define('XFOOD_PATH', BASE_PATH . '/public/images/xfood/');
define('XDEALS_PATH', BASE_PATH . '/public/images/xdeals/');
 
define('CATEGORYOG_PATH', BASE_PATH . '/public/images/categoryog/');
 
    define('ROOT_PATH', dirname(__DIR__));
    $config = include APP_PATH . "/Config/config.php";
 
//try {
 
    /**
     * The FactoryDefault Dependency Injector automatically registers
     * the services that provide a full stack framework.
     */
 
    $di = new FactoryDefault();
 
    //Specify routes for modules
    $di->set('router', function () {
 
        $router = new Router();
 
        $router->setDefaultModule("user");
 
        $router->add(
            "/:controller/:action",
            array(
                "module"     => 'user',
                "controller" => 1,
                "action"     => 2
            ));
 
        // $router->add(
        //     "/:controller/:action/:params",
        //     array(
        //         "module"     => 'user',
        //         "controller" => 1,
        //         "action"     => 2,
        //         "params"     => 3
        //     ));
 
        $router->add('/:controller/:action/:params',
        array(
            "module"     => 'user',
            "controller"=>1,
            "action"=>2,
            "params"=>3
        )
        )->convert('action', function($action){
            return lcfirst(Phalcon\Text::camelize($action));
        });
 
 
 
 
        return $router;
    });
 
    
 
 
require_once(APP_PATH . '/Library/DiFile.php');
   
    $di->setShared('connection', function () use ($config) {
        return new \Phalcon\Db\Adapter\Pdo\Mysql([
            "host" => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname" => $config->database->dbname,
        ]);
     });
 
 
$di->setShared('session', function() {
 
    // $session = new \Phalcon\Session\Adapter\Stream();
    // $session->start();
    // return $session;
 
    $session = new Phalcon\Session\Manager();
    $files = new Phalcon\Session\Adapter\Stream( [
        'savePath' => '/tmp',
    ]);
    $session->setAdapter($files)->start();
    return $session;
 
});
 
    // $di->setShared('random', function() {
    //     $random = new Phalcon\Security\Random();
     
    //     return $random;
    // });
 
    $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;
    });
 
    $di->setShared('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;
    });
 
 
      $di->set(
    "logger",
    function () {
        $logger = new FileAdapter("__DIR__ . '/../../Xpatlink/logger.log");
 
        return $logger;
    }
    );
 
 
    $di->setShared('controllerPath', function () {
       
        if (!empty($_SERVER['REQUEST_URI'])) {
            $uriParts = explode('?', $_SERVER['REQUEST_URI']);
            $segment = explode('/', $uriParts[0]);
           // $uri = str_replace('/', '', $uriParts[0]);
            $uri = $segment[1].'/';
        } else {
            $uri = '/';
        }
        return $uri;
    });
 
    $di->set('users',function () {
 
            include APP_PATH . '/Services/Users.php';
            return new Users();
        },
        true
    );
 
     $di->set('categories',function () {
 
            include APP_PATH . '/Services/Categories.php';
            return new Categories();
        },
        true
    );
 
     $di->set('advertise',function () {
 
            include APP_PATH . '/Services/Advertise.php';
            return new Advertise();
        },
        true
    );
 
    $di->set('directpay',function () {
 
            include APP_PATH . '/Services/Directpay.php';
            return new Directpay();
        },
        true
    );
 
    $di->set('item',function () {
 
            include APP_PATH . '/Services/Item.php';
            return new Item();
        },
        true
    );
 
   
     $di->set('redis',function () {
 
 
            include BASE_PATH . '/vendor/autoload.php';
 
            include BASE_PATH . '/vendor/predis/Autoloader.php';
 
            Predis\Autoloader::register();
 
           /* $client = new Predis\Client();
            $client->set('foo', 'bar');
            $value = $client->get('foo');*/
 
            $redis = new Predis\Client(array(
                "scheme" => "tcp",
                "host" => "127.0.0.1",
                "port" => 6379
            ));
 
            return $redis;
 
        });
    $application = new \Phalcon\Mvc\Application($di);
 
        //Create an application
 
    // Register the installed modules
    $application->registerModules(
        array(
            'user' => array(
                'className' => 'Xpatlink\Modules\User\Module',
                'path'      => APP_PATH.'/Modules/User/Module.php',  
 
            ),
            'admin' => array(
                'className' => 'Xpatlink\Modules\Admin\Module',
                'path'      => APP_PATH.'/Modules/Admin/Module.php',  
 
            ),
        )
    );
    $request = new \Phalcon\Http\Request();
    echo $application->handle($request->getURI())->getContent();
 
/*} catch (\Exception $e) {
    echo $e->getMessage() . '<br>';
    echo '<pre>' . $e->getTraceAsString() . '</pre>';
}*/
KeyValue
_url/category/view/boot-sales
KeyValue
PHP_INI_SCAN_DIR/etc/php.d/:/home/xpatlink/apps/xpatweb/
USERxpatlink
HOME/home/xpatlink
SCRIPT_NAME/public/index.php
REQUEST_URI/category/view/boot-sales
QUERY_STRING_url=/category/view/boot-sales
REQUEST_METHODGET
SERVER_PROTOCOLHTTP/1.1
GATEWAY_INTERFACECGI/1.1
REDIRECT_URL/public/category/view/boot-sales
REDIRECT_QUERY_STRING_url=/category/view/boot-sales
REMOTE_PORT37626
SCRIPT_FILENAME/home/xpatlink/apps/xpatweb/public/index.php
SERVER_ADMIN[no address given]
CONTEXT_DOCUMENT_ROOT/home/xpatlink/apps/xpatweb/
CONTEXT_PREFIX/
REQUEST_SCHEMEhttp
DOCUMENT_ROOT/home/xpatlink/apps/xpatweb
REMOTE_ADDR34.236.152.203
SERVER_PORT80
SERVER_ADDR127.0.0.1
SERVER_NAMExpatlink.info
SERVER_SOFTWAREApache
SERVER_SIGNATURE<address>Apache Server at xpatlink.info Port 80</address>\n
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
HTTP_USER_AGENTclaudebot
HTTP_ACCEPT*/*
HTTP_CONNECTIONupgrade
HTTP_X_FORWARDED_SSLon
HTTP_X_FORWARDED_PROTOhttps
HTTP_HTTPSon
HTTP_FORWARDED_REQUEST_URI/category/view/boot-sales
HTTP_X_FORWARDED_SERVERxpatlink.info
HTTP_X_FORWARDED_HOSTxpatlink.info
HTTP_HOSTxpatlink.info
proxy-nokeepalive1
HTTPSon
UNIQUE_IDZfjydjdmp7SFXHLkA5UpTQAAAFc
REDIRECT_STATUS200
REDIRECT_HTTPSon
REDIRECT_UNIQUE_IDZfjydjdmp7SFXHLkA5UpTQAAAFc
REDIRECT_REDIRECT_STATUS200
REDIRECT_REDIRECT_HTTPSon
REDIRECT_REDIRECT_UNIQUE_IDZfjydjdmp7SFXHLkA5UpTQAAAFc
FCGI_ROLERESPONDER
PHP_SELF/public/index.php
REQUEST_TIME_FLOAT1710813814.2258
REQUEST_TIME1710813814
#Path
0/home/xpatlink/apps/xpatweb/public/index.php
1/home/xpatlink/apps/xpatweb/Xpatlink/Config/config.php
2/home/xpatlink/apps/xpatweb/Xpatlink/Library/DiFile.php
3/home/xpatlink/apps/xpatweb/Xpatlink/Modules/User/Module.php
4/home/xpatlink/apps/xpatweb/Xpatlink/Modules/User/controllers/CategoryController.php
5/home/xpatlink/apps/xpatweb/Xpatlink/Modules/User/controllers/ControllerBase.php
6/home/xpatlink/apps/xpatweb/Xpatlink/Modules/User/models/Mainmeta.php
7/home/xpatlink/apps/xpatweb/Xpatlink/Services/Categories.php
8/home/xpatlink/apps/xpatweb/Xpatlink/Modules/User/models/Categories.php
Memory
Usage2097152