[root@STAG-WEB-SERVER cloudadmin]# sudo unlink /etc/localtime
[root@STAG-WEB-SERVER cloudadmin]# sudo ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.5.50, for Linux (x86_64) using readline 5.1
Connection id: 142820
Current database: mydbname
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.50 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 27 days 11 min 22 sec
Threads: 3 Questions: 6566002 Slow queries: 10 Opens: 335722 Flush tables: 1 Open tables: 400 Queries per second avg: 2.813
--------------
insert into dbt_mis_tracker(scheme_id,ministry_id,status)(select s.id,s.ministry_id,s.status from dbt_scheme s where s.status=1 and s.language=2)
var text_max = 200;
$('#count_message').html(text_max + ' remaining');
$('#text').keyup(function() {
var text_length = $('#text').val().length;
var text_remaining = text_max - text_length;
$('#count_message').html(text_remaining + ' remaining');
});
Using Composer is a tool for dependency management. The candidate can declare the libraries your product relies on and Composer will manage the installation and updating of the libraries. The benefit is a consistent way of managing the libraries depended on so less time is spent managing the libraries.
MySQL 5.0 Column Count Limits: There is a hard limit of 4096 columns per table, but the effective maximum may be less for a given table. The exact limit depends on several interacting factors. Every table (regardless of storage engine) has a maximum row size of 65,535 bytes.
In InnoDB, with a limit on table size of 64 terabytes and a MySQL row-size limit of 65,535 there can be 1,073,741,824 rows. That would be minimum number of records utilizing maximum row-size limit. However, more records can be added if the row size is smaller.
$this->headScript()->appendFile('/js/jquery-ui.min.js', 'text/javascript');
$this->headLink()->appendStylesheet('/css/jquery-ui.min.css');
open httpd.conf file and add/edit below line:
ServerTokens Prod
ServerSignature Off
TraceEnable off
Restart the server and restart browser
You can also check using linux command:
curl -I http://104.211.97.98/dev/
open php.ini file and add/edit below line:
expose_php = Off
Restart the server and restart browser
You can also check using linux command:
curl -I http://104.211.97.98/dev/
No, I am afraid not, since the hash (the string including the #) never gets passed to the server, it is solely a behavioural property of the browser. The $_SERVER['REQUEST_URI'] variable will contain the rest however.
If you really need to know what the hash is, you will have to use the document.location.hash JavaScript property, which contains the contents of the hash (you could then insert it in a form, or send it to the server with an ajax request).
Using this below code, we can redirect a URL from http to https
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Using this below code, we can redirect a URL from http to https
Redirect https to http
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
/1 * * * * wget -O - http://localhost/district/sendmail >/dev/null 2>&1
That should work for you. Just have a wget script that loads the page.
Using -O - means that the output of the web request will be sent to STDOUT (standard output)
by adding >/dev/null we instruct standard output to be redirect to a black hole. by adding 2>&1 we instruct STDERR (errors) to also be sent to STDOUT, and thus all output will be sent to a blackhole. (so it will load the website, but never write a file anywhere)
-----------------------------------------------------
*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1¶m2=2'
*/5 * * * * wget http://example.com/check
----------------------------------------------
You don't need the redirection, use only
* * * * * wget -qO /dev/null http://yoursite.com/tasks.php
--------------------------------------------
You can use curl as is in this thread
*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1'
----------------------------------------------
0 * * * * wget -O - -q -t 1 http://CRON_URL
The rest of the line wget -O - -q -t 1 basically tells the server to request a url, so that the server executes the cron script
Examples
Every 1 minute * * * * *
Every 15 minutes */15 * * * *
Every 30 minutes */30 * * * *
Every 1 hour 0 * * * *
Every 6 hours 0 */6 * * *
Every 12 hours 0 */12 * * *
Once a day 4 0 * * *
Once a week 4 0 * * 0
Once a month 4 0 1 * *
Here is a diagram of the general crontab syntax, for illustration:
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 6) (Sunday=0)
# | | | | |
* * * * * command to be executed
Thus, the cron command example above means "ping
Add ONE of the following lines:
45 * * * * /usr/bin/lynx -source http://example.com/cron.php
45 * * * * /usr/bin/wget -O - -q -t 1 http://www.example.com/cron.php
45 * * * * curl -s http://example.com/cron.php
This would have a lynx, wget, or curl visit your cron page 45 minutes after every hour.
Three options are provided in case either wget, lynx or curl are not installed on the server. Any will do the job well.
$currency = new Zend_Currency('en_IN');
$ccc='1234567890009.84';
echo $this->currency()->setCurrency($currency)->currency($ccc);//output: Rs 12,34,56,78,90,009.80
#!/bin/sh
now="$(date +'%d_%m_%Y_%H_%M_%S')"
filename="dbfilename_$now".sql
backupfolder="/backup/db"
fullpathbackupfile="$backupfolder/$filename"
PASS=password
mysqldump -u root -p$PASS --lock-tables=false --databases dbtdev > $fullpathbackupfile
echo "Backup has been completed!!!"
exit 0
=IF(H3="ABP","APB","NON_APB")
=IF(D3="Cash",1,IF(D3="In Kind",2,IF(D3="Cash and In Kind",5,IF(D3="Other Transfers",3))))
MySQL: Determine which database is selected?
mysql> use bharat;
Database changed
mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| bharat |
+------------+
1 row in set (0.00 sec)
SET time_zone='+00:00';
SET time_zone ='+03:00';
SET GLOBAL time_zone = "Asia/Calcutta";
SET time_zone = "+05:30";
SET @@session.time_zone = "+05:30";
mysql> SELECT @@system_time_zone;
+--------------------+
| @@system_time_zone |
+--------------------+
| IST |
+--------------------+
1 row in set (0.00 sec)
<?php
function mysql_current_db() {
$r = mysql_query("SELECT DATABASE()") or die(mysql_error());
return mysql_result($r,0);
}
?>
Check /etc/my.cnf. Under the [mysqld] section, if you have a open_files_limit variable, increase it, eg:
open_files_limit=32768
Confirm in mysql itself by checking the open_files_limit variable to ensure it's increased, by running the SQL query:
mysql> show global variables like 'open%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| open_files_limit | 32768 |
+------------------+-------+
1 row in set (0.01 sec)
E_ERROR: A fatal error that causes script termination
E_WARNING: Run-time warning that does not cause script termination
E_PARSE: Compile time parse error
E_NOTICE: Run time notice caused due to error in code
E_CORE_ERROR: Fatal errors that occur during PHP’s initial startup (installation)
E_CORE_WARNING: Warnings that occur during PHP’s initial startup
E_COMPILE_ERROR: Fatal compile-time errors indication problem with script
E_USER_ERROR: User-generated error message
E_USER_WARNING: User-generated warning message
E_USER_NOTICE: User-generated notice message
E_STRICT: Run-time notices
E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
E_ALL: Catches all errors and warnings
E_DEPRECATED
E_USER_DEPRICATED
$this->render('index', null, true);
date -s "21 Jan 2017 12:53:00"
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| hostname | Dell |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.5.50 |
+-----------+
1 row in set (0.00 sec)
UPDATE table1 AS t1, table1 AS t2
SET t1.name2 = (t2.name1 + t2.name2)
WHERE t2.id = t1.id and t1.name1>0
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
//or
<?php
$email = "test@example.org";
$expression = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
if (preg_match($expression, $email)) {
echo "Email format is correct!";
} else {
echo "Email format is NOT correct!";
}
?>
//The code below shows a simple way to check if the name field only contains letters and whitespace. If the value of the name field is not valid, then store an error message:
$name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
$website = test_input($_POST["website"]);
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";
}
=VLOOKUP(C3,'D:\Projects\dbt\data\live data by ravi sir\mgnrega\state_wise_mgnrega_2\[nrega_location_master_08072016.xlsx]Districts'!$B$2:$C$662,2,FALSE)
There are many advantages using .htaccess file in PHP:
URL redirecting
Managing error pages
Password Protection
Visitor blocking facilities by IP address
Setting Config variable and Environment variable
PHP provides a number of ‘magic’ methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met.
Give me some examples of majix methods?
__construct()
The __construct() method is by far the most commonly used magic method. This is where you do any initialization you need when an object is created.
__destruct()
The __destruct() method is called when the object is destroyed. It accepts no arguments and is commonly used to perform any cleanup operations such as closing a database connection.
__get()
The __get() method is called when code attempts to access a property that is not accessible. It accepts one argument, which is the name of the property. It should return a value, which will be treated as the value of the property.
__set()
The __set() method is called when code attempts to change the value a property that is not accessible. It accepts two arguments, which are the name of the property and the value.
__isset()
The __isset() method is called when code calls isset() on a property that is not accessible. It accepts one argument, which is the name of the property. It should return a Boolean value representing the existence of a value.
__unset()
The __unset() method is called when code attempts to unset() a property that is not accessible. It accepts one argument, which is the name of the property.
__toString()
The __toString() method is called when code attempts to treat an object like a string. It accepts no arguments and should return a string.
__set_state()
The static __set_state() method is called when the var_export() function is called on our object.
__clone()
The __clone() method can be used to solve this problem. It is called on the copy of a cloned object after cloning takes place.
__sleep()
The __sleep() method is called when the serialize() function is called on the object. It accepts no arguments and should return an array of all properties that should be serialized.
__wakeup()
The __wakeup() method is called when the unserialize() function is called on the stored object. It accepts no arguments and does not need to return anything. Use it to reestablish any database connection.
__call()
The __call() is called when code attempts to call inaccessible or nonexistent methods. It accepts two arguments: the name of the called method and an array of arguments.
__callStatic()
The __callStatic() (available as of PHP version 5.3) is identical to __call() except that it is called when code attempts to call inaccessible or nonexistent methods in a static context.
__invoke()
The __invoke() is called when code tries to use the object as a function. Any arguments defined in this method will be used as the function arguments.
__autoload()
This is not a magic method, but it is still very useful. The __autoload() function is automatically called when a class that doesn’t exist is referenced.
PSRs are PHP Standards Recommendations that aim at standardising common aspects of PHP Development.
An example of a PSR is PSR-2, which is a coding style guide.
There are four types of errors in PHP.
Warning errors
Notice errors
Fatal errors
Parse errors
New features from PHP 7 are:
Scalar type declarations – Scalar type declarations come in two flavors. One is coercive and the other one is strict.
Return type declarations
Null coalescing operator
Spaceship operator
Constant arrays using define()
Anonymous classes
Unicode codepoint escape syntax
Closure::call()
It is the way to reference an instance of a class from within itself, the same as many other object-oriented languages. $this refers to the class you are in. In PHP, the pseudo-variable $this is available when a method is called from within an object context.
stdClass is a PHP generic empty class and stdClass is used to create the new Object. stdClass is a kind of Object in Java or object in Python but not actually used as universal base class.
The difference between the loosely == equal operator and the strict === identical operator is:
$a == $b ? Equal ? TRUE if $a is equal to $b after type juggling.
$a === $b ? Identical ? TRUE if $a is equal to $b, and they are of the same type.
An empty string is a value, but is just empty. Null is special to a database. Null has no bounds, it can be used for string , integer , date , etc. fields in a database. NULL isn’t allocated any memory, the string with NUll value is just a pointer which is pointing to nowhere in memory.
undefined means a variable has been declared but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value. Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.
PHP provides a number of ‘magic’ methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met.
In PHP when you output something (do an echo or print) if has to send the HTTP headers at that time. If you turn on output buffering you can output in the script but PHP doesn’t have to send the headers until the buffer is flushed. This will turn output buffering out without the need to call ob_start().
One should folow a PSR because coding standards often vary between developers and companies. This can cause issues when reviewing or fixing another developer’s code and finding a code structure that is different from yours. A PSR standard can help streamline the expectations of how the code should look, thus cutting down confusion and in some cases, syntax errors.
Use $this to refer to the current object. Use self to refer to the current class.