Skip to content

Instantly share code, notes, and snippets.

@cozingo
cozingo / toggleElement.js
Created February 22, 2017 12:34
toggle button to disable/enable
$("#element").prop("disabled", !$("#element").prop("disabled"));
@cozingo
cozingo / yiit.php
Created February 22, 2017 12:35
insert Yii:t messages to database
$messages_arr = [
'ru' => require('../../common/messages/ru/main.php'),
'en' => require('../../common/messages/en/main.php'),
'uz' => require('../../common/messages/uz/main.php'),
];
foreach ($messages_arr as $lang => $messages) {
foreach ($messages as $key=>$value){
$sm = SourceMessage::find()->where(['message'=>$key, 'category' => 'main'])->one();
if($sm){
@cozingo
cozingo / userData.php
Created February 22, 2017 12:36
get user browser os ip
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
//to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
@cozingo
cozingo / ajax.php
Created February 22, 2017 12:39
yii ajax query
$.ajax({
url: "/site/",
data: {},
success: function(data) {},
});
@cozingo
cozingo / timestamp.php
Created February 23, 2017 06:06
take datetime string and get its timestamp
Yii::$app->formatter->asTimestamp()
@cozingo
cozingo / httrack.txt
Created February 23, 2017 06:18
web site copier with all styles html scripts
httrack.com
@cozingo
cozingo / contentBlock.php
Created February 23, 2017 11:14
from view to layout pass variable
$this->beginBlock('name');
echo name;
$this->endBlock();
@cozingo
cozingo / signup.php
Created February 24, 2017 10:26
register new user in yii2
site/signup
@cozingo
cozingo / input.php
Created February 24, 2017 10:40
Various form fields in yii2
<?= $form->field($model,'company_id')->hiddenInput(['value' => Yii::$app->user->identity->company_id ]);?>
@cozingo
cozingo / null_and_default.txt
Created February 25, 2017 05:41
null and default null difference in phpmyadmin
Null column is like NOT NULL in query for int will not accept empty value only 0 or some other number, for char its acceptable as "" is value for char.
Default means if it is empty it will be set to NULL or to current timestamp or something to DEFAULT VALUE which is set by user.