#5 | Phalcon\Mvc\Application->handle
/home/sahara/apps/hllgimloknjl/public/index.php (909) <?php
//echo phpinfo(); exit;
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;
use Phalcon\Html\Helper\Doctype;
use Phalcon\Html\Escaper;
$escaper = new Escaper();
$helper = new Doctype($escaper);
//(new \Phalcon\Debug)->listen();
use Phalcon\Support\Debug;
$debug = new Debug();
$debug->listen();
define('BASE_PATH', dirname(__DIR__));
define("BASE_URL", 'https://'. $_SERVER['HTTP_HOST']);
define('APP_PATH', BASE_PATH . '');
define('ADVERTS_PATH', APP_PATH . '/public/images/kabisa/');
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();
$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,
]);
});
require_once(APP_PATH . '/library/DiFile.php');
//Specify routes for modules
$di->set('router', function () {
$router = new Router();
$module = 'www';
$router->setDefaultModule($module);
$router->add(
"/",
array(
"module" => $module,
"controller" => 'index',
"action" => 'index',
));
$router->add(
"/:controller",
array(
"module" => $module,
"controller" => 1,
"action" => 'index'
));
$router->add(
"/:controller/",
array(
"module" => $module,
"controller" => 1,
"action" => 'index'
));
$router->add(
"/:controller/:action",
array(
"module" => $module,
"controller" => 1,
"action" => 2
));
$router->add('/:controller/:action/',
array(
"module" => $module,
"controller"=>1,
"action"=>2,
"params"=>3
)
);
$router->add('/:controller/:action/:params',
array(
"module" => $module,
"controller"=>1,
"action"=>2,
"params"=>3
)
);
$router->add('/:controller/:action/{LEVEL_1}/:params',
array(
"module" => $module,
"controller"=>1,
"action"=>2,
"level1"=>3,
"params"=>4
)
);
// $router->add(
// "/returns",
// array(
// "module" => $module,
// "controller" => 'returns',
// "action" => 'index'
// ));
// $router->add(
// "/advertise",
// array(
// "module" => $module,
// "controller" => 'advertise',
// "action" => 'index'
// ));
// $router->add(
// "/advertise/:action",
// array(
// "module" => $module,
// "controller" => 'advertise',
// "action" => 1
// ));
// $router->add(
// "/advertise/:action/",
// array(
// "module" => $module,
// "controller" => 'advertise',
// "action" => 1
// ));
// $router->add(
// "/area",
// array(
// "module" => $module,
// "controller" => 'area',
// "action" => 'index'
// ));
// $router->add(
// "/tracking",
// array(
// "module" => $module,
// "controller" => 'tracking',
// "action" => 'index'
// ));
// $router->add(
// "/sell",
// array(
// "module" => $module,
// "controller" => 'sell',
// "action" => 'index'
// ));
// $router->add(
// "/shipping-rates",
// array(
// "module" => $module,
// "controller" => 'shipping-rates',
// "action" => 'index'
// ));
// $router->add(
// "/our-terms",
// array(
// "module" => $module,
// "controller" => 'our-terms',
// "action" => 'index'
// ));
// $router->add(
// "/privacy-notice",
// array(
// "module" => $module,
// "controller" => 'privacy-notice',
// "action" => 'index'
// ));
// $router->add(
// "/faq",
// array(
// "module" => $module,
// "controller" => 'faq',
// "action" => 'index'
// ));
// categories
// $categories = ['electronics','automobile', 'deals','fashion'];
// foreach ($categories as $key => $value) {
// $url = str_replace(' ', '', strtolower($value));
// $router->add(
// "/".$value,
// array(
// "module" => $module,
// "controller" => 'items',
// "action" => 'index',
// ));
// $router->add(
// "/".$value."/",
// array(
// "module" => $module,
// "controller" => 'items',
// "action" => 'index',
// ));
// $router->add(
// "/".$value."/:params",
// array(
// "module" => $module,
// "controller" => 'items',
// "action" => 'index',
// "params" => 2,
// ));
// $router->add(
// "/:controller/:action",
// array(
// "module" => $module,
// "controller" => 'items',
// "action" => 2
// ));
// $router->add(
// "/:controller/:action/:params",
// array(
// "module" => $module,
// "controller" => 'items',
// "action" => 2,
// "params" => 3
// ));
// }
//end categories
$json = file_get_contents(APP_PATH . '/library/locations.json');
$locations = json_decode($json);
foreach ($locations as $key => $value) {
$router->add(
"/".$value->url,
array(
"module" => 'locations',
"controller" => 'index',
"action" => 'index',
"location" => $value->name
));
$router->add(
"/".$value->url."/",
array(
"module" => 'locations',
"controller" => 'index',
"action" => 'index',
));
$router->add(
"/".$value->url."/:controller/",
array(
"module" => 'locations',
"controller" => 'items',
"action" => 'index',
));
$router->add(
"/".$value->url."/:controller/:params",
array(
"module" => 'locations',
"controller" => 'items',
"action" => 'index',
"params" => 2,
));
$router->add(
"/".$value->url."/:controller/:action",
array(
"module" => 'locations',
"controller" => 'item',
"action" => 2
));
$router->add(
"/".$value->url."/:controller/:action/:params",
array(
"module" => 'locations',
"controller" => 'item',
"action" => 2,
"params" => 3
));
}
// end locations
// // pages
// $pages = array();
// $pages['saharasolutions'] = 'Sahara Solutions';
// $pages['carstore'] = 'Car Store';
// foreach ($pages as $key => $value) {
// $router->add(
// "/".$key,
// array(
// "module" => 'pages',
// "controller" => 'index',
// "action" => 'index',
// "name" => $value,
// "handle" => $key,
// ));
// $router->add(
// "/".$key."/",
// array(
// "module" => 'pages',
// "controller" => 'index',
// "action" => 'index',
// "name" => $value,
// "handle" => $key,
// ));
// $router->add(
// "/".$key."/:controller/",
// array(
// "module" => 'pages',
// "controller" => 1,
// "action" => 'index',
// "name" => $value,
// "handle" => $key,
// ));
// $router->add(
// "/".$key."/:controller/:params",
// array(
// "module" => 'pages',
// "controller" => 1,
// "action" => 'index',
// "params" => 2,
// "name" => $value,
// "handle" => $key,
// ));
// $router->add(
// "/".$key."/:controller/:action",
// array(
// "module" => 'pages',
// "controller" => 1,
// "action" => 2,
// "name" => $value,
// "handle" => $key,
// ));
// $router->add(
// "/".$key."/:controller/:action/:params",
// array(
// "module" => 'pages',
// "controller" => 1,
// "action" => 2,
// "params" => 3,
// "name" => $value,
// "handle" => $key,
// ));
// }
// //end pages
// // carstore pages
//images
$images = array();
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/automobile/38NO18AT24V/1.jpg'] = 'carstorehhrangerover';
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/automobile/38NO18AT24V/2.jpg'] = 'carstorehhrangerover2';
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/automobile/38NO18AT24V/3.jpg'] = 'carstorehhrangerover3';
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/automobile/38NO18AT24V/4.jpg'] = 'carstorehhrangerover4';
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/automobile/38NO18AT24V/5.jpg'] = 'carstorehhrangerover5';
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/automobile/39NO18AT24V/pegiot.jpg'] = 'pegiotamexsevens';
$images['/home/sahara/apps/hllgimloknjl/sdrive/files/images/categories/computing/40NO18AT24V/elite.jpg'] = 'laptophvjsiss';
foreach ($images as $key => $value) {
$router->add(
"/".$value,
array(
"module" => 'www',
"controller" => 'image',
"action" => 'index',
"path" => $key,
"name" => $value,
));
$router->add(
"/".$value."/",
array(
"module" => 'www',
"controller" => 'image',
"action" => 'index',
"path" => $key,
"name" => $value,
));
$router->add(
"/".$value."/{token}",
array(
"module" => 'www',
"controller" => 'image',
"action" => 'index',
"path" => $key,
"name" => $value,
"token" => 1,
));
}
//end images
// // end car store pages
// influencer
$influencer = array();
$influencer['kinyanjuigitau'] = 'Kinyanjui Gitau';
foreach ($influencer as $key => $value) {
$router->add(
"/".$key,
array(
"module" => 'influencer',
"controller" => 'index',
"action" => 'index',
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/",
array(
"module" => 'influencer',
"controller" => 'index',
"action" => 'index',
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/",
array(
"module" => 'influencer',
"controller" => 1,
"action" => 'index',
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/:params",
array(
"module" => 'influencer',
"controller" => 1,
"action" => 'index',
"params" => 2,
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/:action",
array(
"module" => 'influencer',
"controller" => 1,
"action" => 2,
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/:action/:params",
array(
"module" => 'influencer',
"controller" => 1,
"action" => 2,
"params" => 3,
"name" => $value,
"handle" => $key,
));
}
//end influencer
// group
$group = array();
$group['@mitumba'] = 'Mitumba';
foreach ($group as $key => $value) {
$router->add(
"/".$key,
array(
"module" => 'group',
"controller" => 'index',
"action" => 'index',
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/",
array(
"module" => 'group',
"controller" => 'index',
"action" => 'index',
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/",
array(
"module" => 'group',
"controller" => 1,
"action" => 'index',
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/:params",
array(
"module" => 'group',
"controller" => 1,
"action" => 'index',
"params" => 2,
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/:action",
array(
"module" => 'group',
"controller" => 1,
"action" => 2,
"name" => $value,
"handle" => $key,
));
$router->add(
"/".$key."/:controller/:action/:params",
array(
"module" => 'group',
"controller" => 1,
"action" => 2,
"params" => 3,
"name" => $value,
"handle" => $key,
));
}
//end group
// automobile
$autoitems = array();
$autoitems['auoj3r3mcBNjfdnru?'] = '2017_randrover_rangerover_price_ksh_15m';
foreach ($autoitems as $key => $value) {
$router->add(
"/".$value,
array(
"module" => $module,
"controller" => 'automobile',
"action" => 'view',
"token" => 1,
));
// $router->add(
// "/auto/".$key,
// array(
// "module" => $module,
// "controller" => 'automobile',
// "action" => 'view',
// ));
}
//end automobile
// chat
$router->add(
"/chat/{token}",
array(
"module" => 'chat',
"controller" => 'connect',
"action" => 'index',
"token" => 1,
));
//end chat
// directory
$router->add(
"/directory",
array(
"module" => 'user',
"controller" => 'directory',
"action" => 'index',
"token" => 1,
));
$router->add(
"/directory/{token}",
array(
"module" => 'user',
"controller" => 'directory',
"action" => 'business',
"token" => 1,
));
//end directory
// listing
$router->add(
"/listing",
array(
"module" => 'www',
"controller" => 'listing',
"action" => 'index',
"token" => 1,
));
$router->add(
"/listing/{token}",
array(
"module" => 'www',
"controller" => 'listing',
"action" => 'product',
"token" => 1,
));
//end listing
//sahara module
$sahara = 'workspace';
$router->add(
"/".$sahara,
array(
"module" => 'sahara',
"controller" => 'index',
"action" => 'index',
));
$router->add(
"/".$sahara."/",
array(
"module" => 'sahara',
"controller" => 'index',
"action" => 'index',
));
$router->add(
"/".$sahara."/:controller",
array(
"module" => 'sahara',
"controller" => 1,
"action" => 'index'
));
$router->add(
"/".$sahara."/:controller/",
array(
"module" => 'sahara',
"controller" => 1,
"action" => 'index'
));
$router->add(
"/".$sahara."/:controller/:action",
array(
"module" => 'sahara',
"controller" => 1,
"action" => 2
));
$router->add("/".$sahara."/:controller/:action/",
array(
"module" => 'sahara',
"controller"=>1,
"action"=>2,
"params"=>3
)
);
$router->add("/".$sahara."/:controller/:action/:params",
array(
"module" => 'sahara',
"controller"=>1,
"action"=>2,
"params"=>3
)
);
return $router;
});
$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__ . '/../../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('flash',function () {
include APP_PATH . '/services/Flash.php';
return new Flash();
},
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(
'www' => array(
'className' => 'Web\Module',
'path' => APP_PATH.'/www/module.php',
),
'sahara' => array(
'className' => 'Sahara\Module',
'path' => APP_PATH.'/sahara/module.php',
), 'locations' => array(
'className' => 'Locations\Module',
'path' => APP_PATH.'/locations/module.php',
),
'pages' => array(
'className' => 'Page\Module',
'path' => APP_PATH.'/pages/module.php',
),
'influencer' => array(
'className' => 'Influencer\Module',
'path' => APP_PATH.'/influencer/module.php',
), 'group' => array(
'className' => 'Group\Module',
'path' => APP_PATH.'/group/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>';
}*/
|