我在Jquery Ajax中使用CodeIgniter3将一些数据插入数据库。
但是,当用户插入以下内容时,我使用csrf_token制作了安全表单数据。
问题我无法在Chrome浏览器上将数据插入数据库,但可以在Firefox中使用。
错误 403禁止和
<div id="container">
<h1>An Error Was Encountered</h1>
<p>The action you have requested is not allowed.</p> </div>
</body>
Run Code Online (Sandbox Code Playgroud)
这是我在配置文件中的配置:
$config['global_xss_filtering'] = TRUE;
$config['csrf_protection'] = TRUE;
$config['csrf_regeneration'] = TRUE;
$config['csrf_token_name'] = 'csrf_token_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_exclude_uris'] = array();
$config['csrf_expire'] = 7200;
Run Code Online (Sandbox Code Playgroud)
我用控制器将一些数据插入数据库
public function post() {
$new_token = $this->security->get_csrf_hash();
$this->form_validation->set_rules($this->ads_m->post_rule);
if ($this->form_validation->run() == FALSE) {
echo json_encode(array('res' => FALSE));
} else {
$data = array(
'name' => $this->input->post("p_name"),
'user_id' …Run Code Online (Sandbox Code Playgroud) 我想从表中选择的列命名的最大值quotationVersion从表中quotation,
getOneMaximumQuotationVersion() {
const query = this.createQueryBuilder("quotation");
query.select("MAX(quotation.quotationVersion)", "max");
// query.addSelect("MAX(quotation.quotationVersion)", "max");
return query.getOne();
}
Run Code Online (Sandbox Code Playgroud) 我已经使用Jquery getScript并通过Javascript生成html表单但是我 在PHPStorm中当前的Javascript版本不支持Shorthand属性名称,但我的功能也可以.
关注:以前我用PHP到另一个PHP框架内生成html形式,但我觉得我不应该使用的服务器脚本这样做,我应该用JS做到这一点,但我不知道这是怎么回事,并且它支持所有浏览器或者不是这样,请给我一些关于这种技术的想法,因为我还没有更多地了解起诉DOM及其性能.
安全问题:如果我使用Javascript生成如下脚本的Html表单,它会降低安全性或不良性能吗?
另一方面,如果我将此代码保留在HTMl中,我将永远不会得到这种错误类型.
$(document).ready(function () {
returnTill('returnTill');
});
function returnTill(returnTill) {
var chief_opt = '';
var teller_opt = '';
$.ajax({
url:'/teller/return_till_data',
method:'get',
dataType:'json',
timeout:4000,
async: false,
success:function (data, status) {
$.each(data, function(ins, vals){
if(ins === 'chief') {
cheifs = data.chief;
for(var key in cheifs){
chief_opt += '<option value="'+vals[key].id+'"> '+vals[key].username+' / '+vals[key].account_no+' </option>';
}
}if(ins === 'teller') { /* Tellers*/
tellers = data.teller;
for(var key in tellers){
teller_opt = '<option value="'+vals[key].id+'"> '+vals[key].username+' / '+vals[key].account_no+' </option>'; …Run Code Online (Sandbox Code Playgroud) 我只是从 Laravel4.2 升级到 Laravel5.3,它在 Localhost 中也能正常工作,但是当上传到服务器时,我遇到了以下错误。
哎呀,看起来出事了。
1/1
FatalThrowableError in AppServiceProvider.php line 18:
Class 'App\Providers\URL' not found
in AppServiceProvider.php line 18
at AppServiceProvider->boot()
at call_user_func_array(array(object(AppServiceProvider), 'boot'), array()) in Container.php line 508
at Container->call(array(object(AppServiceProvider), 'boot')) in /var/www/backoffice/vendor/laravel/framework/src/Illuminate/Foundation/Application.php line 769
at Application->bootProvider(object(AppServiceProvider)) in /var/www/backoffice/vendor/laravel/framework/src/Illuminate/Foundation/Application.php line 752
at Application->Illuminate\Foundation\{closure}(object(AppServiceProvider), '15')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FoundationServiceProvider), object(NotificationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(HtmlServiceProvider), object(ExcelServiceProvider), object(DatatablesServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(EventServiceProvider), object(RouteServiceProvider)), object(Closure)) in Application.php line 753
at Application->boot() in BootProviders.php line 17
at BootProviders->bootstrap(object(Application)) …Run Code Online (Sandbox Code Playgroud) 我正在使用Jquery插件Nestable进行菜单编辑.我希望所有菜单项都自动折叠,但也要在用户点击每个可展开图标时展开.
这是Jquery Nestable插件.
$(document).ready(function(){
$("#product_list").nestable({
maxDepth: 10,
collapsedClass:'dd-collapsed',
});
});
Run Code Online (Sandbox Code Playgroud) 我正在使用PHP来回应来自DB的产品.如果我们只使用foreach将得到每个循环一个项目的结果,但实际上我希望它每次回显两个项目,如下所示
这是我的PHP函数,使用foreach从DB获取数据
我用行项目选择包装产品的选择,所以我想呼应块的产品,然后两次将呼应行项目.
示例:row item = 1 then product = 2
public function last_upated_products() {
$data = $this->newest_products_from_db('products');
$out = '';
if ($data) {
foreach ($data as $k => $row) {
$out .= '<div class="row item">';
$out .= '<div class="product">';
$out .= '<div class="image">';
$out .= '<a href=""><img src="' . base_url('asset/img/main/9.jpg') . '" alt="img" class="img-responsive"></a>';
$out .= '<div class="promotion"><span class="discount">' . $row['prod_id'] . '% OFF</span> </div>';
$out .= '</div>';
$out .= '<div …Run Code Online (Sandbox Code Playgroud) 我通过干预/图像从Laravel4.2升级到Laravel5.3:“ ^ 2.3”,
if (Input::hasFile('logo')) {
$path = public_path()."/assets/admin/layout/img/";
File::makeDirectory($path, $mode = 0777, true, true);
$image = Input::file('logo');
$extension = $image->getClientOriginalExtension();
$filename = "logo.$extension";
$filename_big = "logo-big.$extension";
Image::make($image->getRealPath())->save($path.$filename);
Image::make($image->getRealPath())->save($path.$filename_big);
$data['logo'] = $filename;
}
Run Code Online (Sandbox Code Playgroud)
结果我出错
Call to undefined method Intervention\Image\Facades\Image::make()
Run Code Online (Sandbox Code Playgroud) 我有这个Javascript对象如下格式,但我想将其转换为另一种格式如下:我传递值格式let data = $('#clientForm').serializeArray(); 原始格式
let data = $('#clientForm').serializeArray();
{ name="addr_types", value="RESID"}
Run Code Online (Sandbox Code Playgroud)
通缉格式
{addr_types:"RESID"}
Run Code Online (Sandbox Code Playgroud)
或者另一种格式
{"addr_types":"RESID"}
Run Code Online (Sandbox Code Playgroud)
javascript ×4
jquery ×4
laravel-5.3 ×2
php ×2
ajax ×1
foreach ×1
html ×1
intervention ×1
laravel ×1
phpstorm ×1
typeorm ×1