草庐IT

Level1Controller

全部标签

php - 如何保护 Controller 不被直接访问?

我正在将codeigniter与jquery结合使用,如果您能向我解释如何保护Controller不被直接访问,那就太好了。例如,我对标准的jquery行有看法:$('#handler').load('tools/get_stats');工具它是我的Controller,具有加载统计信息的功能。如果我直接在浏览器中写入脚本的完整地址http://site.com/tools/get_stats,浏览器打开,当然是那个数据。如何保护浏览器的直接Controller访问?我希望我的数据仅在View中加载,而不是在Controller直接访问中加载。 最佳答案

php - codeigniter 将数组数据从模型传递到 Controller

我在模型的get_distribuidor()函数中执行以下查询:publicfunctionget_distribuidor(){$this->load->helper('url');$query=$this->db->query("SELECT*FROMdistribuidorwhereid_distribuidor='1';");foreach($query->result_array()as$row){echo$row['id_distribuidor'];echo$row['nome_empresa'];echo$row['cod_postal'];echo$row['loc

php - 无法将数据从 Controller 传递到 Blade 模板 laravel

在我的页面Controller中有$this->layout->content=View::make('authentication/login')->with('page_title','title');我正在为我的模板使用Blade文件。在html的头部,我有{{$page_title}}我得到一个错误,提示$page_title未定义。理想情况下,我想要的是$data=array('page_title'=>'Login','second_item'=>'value')...。但由于我无法将变量基本传递给View,所以我首先坚持这样做。 最佳答案

php - Laravel 4 Controller 中的依赖注入(inject)实例所有对象

我想在Laravel4Controller中编写可测试的代码。我知道DI(依赖注入(inject)),我知道可测试代码可能如下所示:classUsersControllerextendsBaseController{publicfunction__construct(User$user,Notice$notice){$this->user=$user;$this->notice=$notice;}publicfunctiongetIndex(){...$this->user...$this->notice...}publicfunctiongetPage(){...$this->use

php - Opencart:从另一个 Controller 调用方法

我需要在checkout/confirm.tpl文件中调用我在controller/product.php中创建的自定义函数制作这个的最佳方法是什么?我已经试过了,但是没有用:$productController=$this->load->model('product/product');$productController->customFunction(); 最佳答案 是的,我终于找到了正确的答案!!!抱歉最后的错误答案classControllerCommonHomeextendsController{publicfuncti

php - Laravel 5 - Controller 中的路由和可变参数

我想在搜索时生成这样的SEO友好URL:http://www.example.com/search(无过滤器)http://**www.example.com/search/region-filterhttp://**www.example.com/search/region-filter/city-filter并以这种方式对它们进行分页:http://www.example.com/search/2(无过滤器,第2页)http://**www.example.com/search/region-filter/2http://**www.example.com/search/regio

php - codeigniter - 升级 php 和 apache 后未找到 fatal error 类 'CI_Controller'

我在升级Apache从2.2.19.0到2.4.16.0和php从5.3.7.0到5.6.12.0现在我得到这个错误:Fatalerror:Class'CI_Controller'notfoundinsystem\core\CodeIgniter.phponline234CodeIgniter.php第221-235行//LoadthebasecontrollerclassrequireBASEPATH.'core/Controller.php';/***ReferencetotheCI_Controllermethod.**ReturnscurrentCIinstanceobject

php - 将数据从 View 传递到 Controller (codeigniter)

我正在尝试使用从View到Controller的链接传递一些数据。Controller:publicfunctiondetails(){echo$this->input->post('data_id');$data['details']=$this->wapi_db->details($this->input->post('data_id'));$data['latest_news']=$this->wapi_db->latest_news();$data['main_content']="category/details";$this->load->view('includes/te

php - 不完全确定( Controller )转发在 Symfony 中是如何工作的

我尝试将一些带有as功能的代码移动到我的页面,添加到现在看起来像这样的某个Controller:1)?($page*$recordsPerPage)-$recordsPerPage:0;//Query//Records://$movies=$this->getDoctrine()->getEntityManager()->getRepository('AppBundle:Movie')->FindAll();$repository=$this->getDoctrine()->getRepository('AppBundle:Movie');//Datatocount:$qb=$repo

php - 文件夹内的文件夹内的 Controller 不起作用(Codeigniter)

我使用codeigniter一直做得很好,但现在我遇到了一些小问题。我不想将所有内容都放在一个Controller文件中,而是想将它重新分发到一个子文件夹中的许多文件中。例如:localhost/folderA/folderB/controllerFile通过这种方式,文件夹B替换了Controller的主文件,并且所有文件都可以分散到这个新文件夹中,因为不需要在一个文件中包含10个不同的Controller功能(这会使它变大)。在route我添加了一条新线$route['folderA/folderB/(:any)/']='folderA/folderB';我什至认为没有必要添加路由