Not all POST array elements getting sent - html

I have a table which has 4 columns with the first column containing a text input boxes. The entire table is wrapped inside a form that will run a PHP script on that data. As of right now, I'm just printing out the POST array. The problem is that I'm missing some of the values that I write into the input fields. So putting the values 1-10 in the first 10 text inputs gives me the following in print_r:
Array
(
[65710] =>
[65705] => 2
[269200318] =>
[269200586] => 4
[16830189] =>
[16829165] =>
[1051902] => 7
[65742] =>
[16830122] =>
[269339822] => 10
}
The HTML for this form can be found here: http://jsfiddle.net/nY9MF/
This is running on IIS 7
Edit: I updated the jsfiddle code to have the full table for one of these stores. This is the POST array after I hit submit:
Array(
[65710] =>
[65705] => 2
[269200318] =>
[269200586] => 4
[16830189] =>
[16829165] =>
[1051902] => 7
[65742] =>
[16830122] =>
[269339822] => 10
[65774] =>
[16821982] =>
[65740] =>
[16825517] =>
[65709] =>
[1051326] =>
[1052334] =>
[65773] =>
[4110] =>
[16837342] =>
[16825518] =>
[1051375] =>
[1051594] =>
[65743] =>
[1052108] =>
[256] =>
[4106] =>
[65711] =>
[65738] =>
[1051597] =>
[4109] =>
[65724] =>
[SaveQuantity] => Save
)

Related

I want to use Jalali date in my Laravel / Angular database but I faced with this error: Whoops, looks like something went wrong

Recently I have purchased "Schoex - Ultimate school management system", a software for managing school. This software designed by Laravel 4 and AngularJS. Default date for this software is Gerigorian and I want to change it to Jalali date. I found different package from internet but not any one worked.
For example I tried to used this package: https://github.com/morilog/jalali
and It shows this error: Whoops, looks like something went wrong.
app.php
<?php
return array(
'debug' => false,
'log' => 'daily',
'url' => '',
'timezone' => 'Asia/Kabul',
'locale' => 'fa',
'key' => 'SchoexSchoolApplicationByCrHouse',
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Remote\RemoteServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'Tappleby\AuthToken\AuthTokenServiceProvider',
'Morilog\JalaliServiceProvider',
),
'manifest' => storage_path().'/meta',
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'SSH' => 'Illuminate\Support\Facades\SSH',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'AuthToken' => 'Tappleby\Support\Facades\AuthToken',
'AuthTokenNotAuthorizedException' => 'Tappleby\AuthToken\Exceptions\NotAuthorizedException',
'jDate' => 'Morilog\Facades\jDate',
'jDateTime' => 'Morilog\Facades\jDateTime',
),
);

CakePHP 3 CounterCache not updating on delete with belongsToMany SelfJoinTable

CakePHP vertion: 3.3.11
CounterCache working on add method but not working on delete method.
SentenceTable
$this->belongsToMany('Sentences', [
'foreignKey' => 'second_sentence_id',
'targetForeignKey' => 'sentence_id',
'joinTable' => 'sentences_sentences'
]);
$this->belongsToMany('SecondSentences', [
'className' => 'Sentences',
'foreignKey' => 'sentence_id',
'targetForeignKey' => 'second_sentence_id',
'joinTable' => 'sentences_sentences'
]);
SentencesSentencesTable
$this->belongsTo('Sentences', [
'foreignKey' => 'sentence_id',
'joinType' => 'INNER'
]);
$this->belongsTo('SecondSentences', [
'className'=>'Sentences',
'foreignKey' => 'second_sentence_id',
'joinType' => 'INNER'
]);
$this->addBehavior('CounterCache', ['Sentences' => ['ver_count']]);
SentencesController Add method updating ver_count
$sentence = $this->Sentences->get($this->request->data['id']);
$sentence = $this->Sentences->patchEntity($sentence, $this->request->data);
$this->Sentences->SecondSentences->saveStrategy('append');
$this->Sentences->save($sentence);
SentencesController delete method not updating ver_count
$sentence = $this->Sentences->SecondSentences->get($this->request->data['id'],['contain'=>['Sentences']]);
if ($sentence->user_id == $this->Auth->user('id')) {
$this->Sentences->SecondSentences->delete($sentence);
$sentences = $this->Sentences->get($sentence->sentences[0]->id,['contain'=>['SecondSentences']]);
// NOW I AM USING BELOW CODE FOR UPDATING VER_COUNT.
$this->Sentences->updateAll(['ver_count'=>count($sentences->second_sentences)], ['id'=>$sentence->sentences[0]->id]);
}
How are your records deleted. Just as mentioned in cakephp documentation (CounterCache):
The counter will not be updated when you use deleteAll(), or execute SQL you have written.
And:
The CounterCache behavior works for belongsTo associations only.
Just confirm about that first.

ZF2 - \Zend\Db\Sql\Expression and DATE_FORMAT

I'm using Zend Framework 2.4 and trying to amend a working SQL columns select from
'content_publish_date' => 'publish_date',
to
'content_publish_date' => new \Zend\Db\Sql\Expression('DATE_FORMAT(\'content.publish_date\',\'%d/%c/%Y\')'),
produces the following SQL...
DATE_FORMAT('content.publish_date','%%d/%%c/%%Y') AS `content_publish_date`,
... which fails syntactically on MySQL (note the extra '%')
I have tried various alternatives...
'content_publish_date' => new \Zend\Db\Sql\Expression('DATE_FORMAT(content.publish_date,\'%d/%c/%Y\')'),
'content_publish_date' => new \Zend\Db\Sql\Expression('DATE_FORMAT(content.publish_date,"%d/%c/%Y")'),
... and so on, none of which has helped.
Does anyone have any idea how to use the Expression correctly to get the correct generated SQL?
The full code for this piece is as follows:
$dbSelect->join(
'content',
'content.id = category.content_id',
array(
'content_title' => 'title',
'content_html_title' => 'html_title',
'content_description' => 'description',
'content_content_text' => 'content_text',
'content_url' => 'url',
'content_url_vars' => 'url_vars',
'content_meta_keyword' => 'meta_keyword',
'content_meta_description' => 'meta_description',
'content_content_type_id' => 'content_type_id',
'content_disclaimer_id' => 'disclaimer_id',
'content_agent_target_id' => 'agent_target_id',
'content_video_position' => 'video_position',
'content_video_size' => 'video_size',
'content_creation_date' => 'creation_date',
'content_publish_date' => new \Zend\Db\Sql\Expression('DATE_FORMAT(\'content.publish_date\',\'%d/%c/%Y\')'),
'content_flag_content_url' => 'flag_content_url',
'content_flags' => 'flags'
),
\Zend\Db\Sql\Select::JOIN_LEFT
);
Thanks in advance.

Ruby: Cleanup my code w/ stored procedure?

this is my first ruby script. I'd like to clean it up. How would I go about storing all of the following nessus_scans.insert() arguments into a variable to reduce duplicate lines in my code? I'd like to store :Id => "", :scan_title => "" etc all into this variable and then just do something like nessus_scans.insert(myvariable). This query is used about 5 times in the code which is why I want to simplify it. Thanks!
nessus_scans.insert(:Id => "",
:scan_title => "#{scan.title}",
:hostname => "#{host.hostname}",
:host_ip => "#{host.ip}",
:mac_addr => "#{host.mac_addr}",
:netbios_name => "#{host.netbios_name}",
:open_ports => "#{host.ports.map(&:inspect).join(', ').tr('"', '')}",
:operating_system => "#{host.operating_system}",
:start_time => "#{host.start_time}",
:stop_time => "#{host.stop_time}",
:runtime => "#{host.runtime}",
:cve => "#{event.cve}",
:cvss_base_Score => "#{event.cvss_base_score}",
:description => "#{event.description}",
:family => "#{event.family}",
:plugin_id => "#{event.plugin_id}",
:output => "#{event.output}",
:event_name => "#{event.name}",
:patch_publication_date => "#{event.patch_publication_date}",
:plugin_version => "#{event.plugin_version}",
:event_port => "#{event.port.number}",
:risk => "#{event.risk}",
:see_also => "#{event.see_also}",
:severity => "#{event.severity.in_words}",
:solution => "#{event.solution}",
:synopsis => "#{event.synopsis}",
:xref => "#{event.xref}",
:bool_crit => "#{event.critical?}",
:bool_high => "#{event.high?}",
:bool_med => "#{event.medium?}",
:bool_low => "#{event.low?}",
:bool_info => "#{event.informational?}")
end # end event.informational?
my_data = {
Id: "",
scan_title: scan.title,
hostname: host.hostname,
...
}
nessus_scans.insert(my_data)
These are all equivalent:
def method(arg1, arg2)
p arg1, arg2
end
method(10, a: 20, b:30)
--output:--
10
{:a=>20, :b=>30}
method(10, {a: 20, b:30})
--output:--
10
{:a=>20, :b=>30}
data = {a: 20, b:30}
number = 10
method 10, data
--output:--
10
{:a=>20, :b=>30}

Zend Framework 2 - Multiple sub domains cause problems

I am writing an application in Zend Framework 2 which is going to run from a few different subdomain, and I want to have a different module for each sub domain, to keep things tidy.
My problem is when I add more than 1 sub domain to the routing, it loses one of the sub domains.
eg: This setup works
testbed.localhost (module/Application)
a.testbed.localhost (module/A)
If I add an extra one it will the route all requests for a to the Application Index Controller
eg
testbed.localhost (module/Application), a.testbed.localhost (module/A), b.testbed.localhost (module/B)
This is the module.config.php for module/A
'router' => array(
'routes' => array(
'ads' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'a.testbed.localhost',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'__NAMESPACE__' => 'A\Controller',
'controller' => 'A\Controller\A',
'action' => 'index',
),
),
And this is the route in module.config.php in module/B
'router' => array(
'routes' => array(
'ads' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'b.testbed.localhost',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'__NAMESPACE__' => 'B\Controller',
'controller' => 'B\Controller\B',
'action' => 'index',
),
),
Now the namespaces are correct in both the module.config.php files, what I have noticed is the sub domain a.testbed.localhost will work if I remove the reference to it from config/application.config.php
<?php
return array(
'modules' => array(
'Application',
'A',
'B', <--- A doesn't work if B is here
),
And if I swap A & B around in the modules array above, then B will get forwarded to the Application Module and A will work. So it seems to have problems with more than 1 sub domain. Has anyone got any ideas / come across the same thing?
This happens because your route names are the same. I would try a-ads and b-ads for route names and that should resolve your situation.
In the end the configuration is getting merged together. So it's like an array, when the last array is merged it overwrites anything before it.